Some refactoring in cartridge code to prepare for RTC support