Added more documentation and clean up