resolve #8 #2 #7 

resolve #8 #2 #7 
see commit messages