Cleaned some code, rearranged a few things, fixed some bugs, added some
final touches, added some comments.