fixed several bugs of the dragging operation.