Refactored ROM code, prepare for multiple cartridge type support. Added debug logging