New parseOpts implementation. Needs cleanup.