Cleaned up a load of core code.