Removed dependency on async.js and refactored