many changes to handle epsilon=0 case