Made several improvements to code and documentation