Backup after getting grep mostly working, though with much cleanup and refactoring needed.