Fix performance problems