Added templating feature and cleaned up parser