Updated documentation and improved code