Refactoring, unity configuration, code analysis fixes