Moved all variables and functions into a self-invoking function.