Beginning of rom scan code