Added initial error handling, templating, and unittests