Add PM merging and fix various issues.