Bugfixes and minor changes