Shrink and Optimize

Reduce size and simplify by consolidating some redundant code.