Fixed minor drag&drop bugs. Added TypeScript

Not fully rewritten in TypeScript