Misc bug fixes, minor code cleanup, initial sd card data logging implementation