Add scan functions to prelude
Move backtracking to a slightly saner place.