Fixed dragndrop bug and refactored event handling