moving template around

(is now a lot closer to the original, shouldn't require updating new
scripts as the structure should fit)
also some minor bugfixes