Refactoring backend api. Also redesignated template output directory to /tmp