Several code optimizations to remove some redundant redundancies, optimizing the code.