Merge pull request #14 from darkstar21/develop

Cleaned up code, added comments
fixed error handling