lots of ugly hacks to make it work a bit smoother