Some refactoring, more comments