Next/prev bug fix and some code cleanup, more brainstorming on log