Clean up code, add comments, alphabetize functions