Optimize output size of kpm pack

parent #652 
We need to be more defensive here.