Implemented error handling. Fixed #1. Updated documentation