Cleaned some of the code for these to files and removed some comments.