Add clearSelection method, code cleanup