Fixes to functions