Quick fix for #5304, print metatages on pages.
Code cleanup and add comments.
Fix wrong logic.
Merge branch '5304' into 5161