fixed bug
added comments, adjusted comments, cleaned up code
removed unused code