refactor a few things, no need to keep data we dont actually use and only ever regenerate
refactor state and template handling