Fixes and templatizing