Added Comments and cleaned up some code