Refactoring (draft)
Merge with master