Add sphinx documentation
Merge branch 'master' into sphinx
Write sphinx documentation and some refactoring