Bug fixes and merging