Refactor module and fix templates