Refactoring and fixes

No match.