Improved documentation and error handling.