reorganized and namespaced to facilitate integration in other projects