did some refactoring and ReSharper magic