Fixes to the code