formatting plus bugfix for non standard templates