Refactor code and bugfix
Merge remote-tracking branch 'origin/master'