Massive clean up, should be decently readable now.