Refactored Namespaces and cleaned up code