Moving functions and variables to correct, working location.