Cleaned up and organized a bunch of code out of the main RPG script file