Some small performance fixes