Improve behaviour on ENTER and little refactoring