Improved error handling and more complete class implementations