Matching function now much faster using indexes on DataFrame, rather than full table scans.
Some minor edits