Refactoring after review
Merge with master