Some refactoring etc.