Fix UnitDef storage. Improve builder-task assignment