Several minor performance improvements