Template admin changed, bug fixes and refactoring