Code now compiles, but with a lot of whining about const-correctness. Need to check generic_exchange.