Some fixes to Frederick's commit