Portability fixes. Declare variables at the start of a scope only.