Added flash erase/read commands and cleaned up the code further