Fixing a couple of long-standing bugs