Better implementation of preParse(). Fixes #505.