Switch to more general types, add monadic lookup newtype.