(cleanup) added comments and grouped related code blocks

- refactored imports
- wrapped get_template return type in a `Result`. for now, it will either wrap `Ok` around a string, or `Err` around an `int`. this `int` will be refactored with a custom error struct when we have one.
- grouped related code together