Added more documentation and corrected some errors