In preparation for changing the on-disk format eventually, as well as making the main code more readable.