Add phase handling to Item_factory

This will also make phase handling more consistent when we finish moving item definitions into the raws (see #869)