Cleaned up phase-activity mapping

Cleaned up the relationships of activities and phases, now uses a
manytomany relation.