Fix few bugs in phase1