Restructured projects and code

Restructured the logging code to avoid cyclic dependencies.