Work in progress -- this code is going to be refactored away.