introduce prefix matching
fixes #641
fixes #604