Cleaned up annoyingly large and disorganized function code and split into smaller functions; turned debugging off