Made rephase and get_phase faster