[Re-factor] Major refactor of code to meet angularJS Standards