Fixes something like 50% of the TS issues. Will spend more time on this soon.
Fix build errors. Fixes #293