Major bugfixes and performance improvements.