Initial refactoring and improvements in the drag directive.