modular refactoring

Broke template into separate modules. This will aid in future
modifications to accomodate optional configurations.