Cleanup

Merge changes from upstream CM and @lomarb