Mainly changes to code