Cleaned up the code, added some comments. I think we're done.