jshint + bug fix - faulty error handing code in gateway