Changed structure and naming

Split ‘firstRun’ and ‘notFirstRun’ into separate functions.
Variable names in camelCase.
Moved variables definition to the top of their scope.