Improved error handling. Removed DataStream.js dependency.