Some performance optimizations

@Matt-Esch