I've made things much faster, but introduced some bugs - fixes to come later.