This should be done first, the current implementation is evil.
See also #2136