Start refactoring

First step, including: 
close #2
fix #10