Fixed a few bugs that were created when moving around code.