Moved declarations to top of function.