More merging and bug fixes