Refactoring API code

Adding underscore library as well for added helpers. become familiar with http://underscorejs.org/