Major refactoring for better architecture using services