Beautification + minor fixes

Moved boxing to its own template and fixed some remaining issues with
template recursion.