comments and minor reordering to match it