Refactoring tables to use views instead of templates