Merge fixes

Minor fixes and code cleanup