Added support for pages and their derivatives. Some general cleanup as well.