move page parsing stuff into separate file, clean up