cleaned up some code particularly in services and controllers