moved template parts to root, added a few template functions, a bit of cleanup, a bit of mess-making