bug fixes and additional performance tweaks