moving declarations closer to their use, fixing up white space, and making identifiers more meaningful