More tests and optimizations.