Black magic to make dim work ok