Fixed some memory stuff, and made sure we don't mess up our globals