Refactored namespaces, fixed bugs