Add documentation to all methods and some minor cleanup