Updated docs and cleaned up code