Cleaned up code by moving things to namespaces