Updating comments, adding functionality, improving exception handling