Adding more docs and some code cleanup