#323: Some refactoring