Merge conflicts

Fixed merge conflicts and a few bugs