huge performance fixes