More WIP: Further implementation of templates and fixing some things broken