Cleaned up merge wackiness, incorporated basic templating