Attempt to get the page dimensions from FITS before checking Djatoka.

Also some clean up and restructuring.