Cleanup & optimization for utils.page_resolver

Saves 1 or 2 database queries from every page fetch. See individual commit messages for explanation.

@ojii, please scrutinize the 2nd commit -- you're the author of that original code. While I can't see any reasonable use for that condition, I might be missing something in my analysis.