Merged in local changes (probably from Wiktor) from doozy