fixed numerous bugs in pages part.