Made the docs more readable. Also made the code cleaner in some places.