lots of changes, making everything as templatable as possible