Add doc strings. Improve error handling.