Reordered functions to reflect calling order.