Added documentation and error handling for all basic functionality