Obviously, it's an ugly hack and I would love to have something better, so suggestions are welcome.