bugfix in diff and speedup in subs.