Added support for custom p2m