Added documentation as well as fixing a few bugs