Added some more documentation, optimized some minor things