various performance fixes