Improve documentation and comments