More functions and less useless variables.