Merged code/fix bugs in merge