Move some declarations closer to where they're used