Slightly optimized code.