Moved the view state and url management into a service.