Some fixes to previous code