Refactored some of pageprovider so that it isn't as messy.