Adding documentation and cleanup