Optimizations

See commit information.