function ordering and other changes