did a lot of work! checkpoint prior to removing debugging and cheating functions