Added copyrights, removed unused imports and tweaked code in selection
handle