Several optimizations for enhancing speed