Cleaned up API and removing mutable globals.