Update to put declarations upfront, according to warnings suggested by compiler (with extra flags)