Cleaned up global scope

moved private functions and variables you don't want to see globally to appropriate place.