apply recent changes by MrWitt