First fixes to code