Fixing and cleaning code