Improved error handling and documentation

+ Fixed bad require of Q library, replaced by Deferred.