Refactor and comment after big merge