Some performance fixes