Various misc improvements/bugfixes.