Closes TMSS-2274. I marked this as draft because this not only needs code review, but actually someone to thinks this through and confirms that this is a good solution under all circumstances.