improved template hierarchy + 1 bugfix