Rearragning the code a bit.