some refactoring and improvements
copyright notice + some comments