performance tweaks, bugfixes