Some refactoring and improvements

Some refactoring and improvements prior to nuget publishing