Added more docs and fixed a few bugs