some refactoring
merge from github