Moved global declarations to local scope