Fixed some jsHint errors and used Array.reduce insteadof underscore.reduce