Assorted fixes to Formula parsing and document scanning.