Improve code and documentation