Ugly, but necessary, as stated in the comment. Sorry for another `doLayout` in the code. If you think we can avoid it, I'm happy to put some effort into that.