Refactor some variables, move constants to constants file, and organize imports.