Refactored some angular code.