Some refactoring and added an example project