Improved selection handling.