bugfixes, new threading implementation