Currently we implement them twice, slightly differently. We should have a single shared implementation.