Improved code and documentation