Moved templating to separate file and added JSON export