Fix autocomplete and refactor and comment