Cleaned up code a little, added some comments