Moved many functions from controllers to services, updated views