Adding documentation and clean up