fixes, move things to templates for modularity, etc