Split core into separate namespaces. Refactor code.