Lots of changes to code