Found a better way to get current page.

This will ensure that we always get the right page. Works much
cleaner than the previous implementation.