Optimizations and bug fixes to CPU based PME