Reordering variables that were being used before they were declared. Fixes compiler crashes.

BS3 commit a35b9b7