Cleaned up comments, changed variable names in some functions for clarity