Minor bugfixes and performance changes.