Some refactoring and templating and initial dployment