Some performance improvments