Replace main memory map with switch statement

Should be faster than checking with if statements