Support Anvil read/write (mostly)

This is the first commit in a large overhaul of the entire library.