Inlined next and current functions.