Rewritten to use new container stuff from core.