Refactoring the angular code a bit before switching to the new api