Some comments and refactoring