Many improvements and bugfixes.