Adding changes from Mote's RNG.lua. Refactoring lots of stuff