Neurodroid's embedded sample PR plus a few changes of my own (cherry picked from commit 32815309d4)
32815309d4