Fixed selection behavior while using Shift key; some code clean up