cleaned up code and added comments
Merge remote-tracking branch 'origin/master'