refactoring
Merge pull request #1 from ivolo/master

refactoring code and api