Some optimizations based on Shimple.