Merging bugs fixes and additions