Made some optimizations.