Added global RUNNING for all while loops. Cleaned up some compiler complaints.