Speed improvements and bugfixes.