Clean-up and Flash.

General clean-up of code, plus addition of some of the flash memory
access functionality.