Fixed almost everything, still a few bugs with merging