fixes and optimisations

cloned bsd which(1)

removed obsolescent things

added match and replace, removed usage and option carry-through

fixes, the things