Moving declarations to start of function for C90 compliance.