fixed few errors in typescript
merged with Michael