Cleaning up some stuff.
Finished, still need to add comments.