Small improvements, refactoring