revamped renumber and fixed all bugs