Small performance fixes

According to the discussion in #262