Drag and drop bug fixes and refactoring