Adds md device support, improved file handling, and PEP8 fixes