Now uses greedy replacement. Fixes #1