minor repairs and optimizations.