Added documentation and did some clean up