AStyled the code
Made some performance adjustments