Some fixes and refactor
Merge remote-tracking branch 'origin/master'