We should write an API for that.