some refactoring + fixed a few of the problematic templates