refactor Draggable code

This is more memory-efficient -- All helper functions only exist once, not a separate copy for each draggable entity. It's also easier to read (in my opinion).