Refactor to namespaces