Greatly optimizes the normalization algorithm and fixes a couple output bugs