Planned revert from 6e151aa1

Some of the changes had unintended side effects and were not properly
tested. They have been reverted back to the stable state.