Move declarations closer to where they're first used