Bunch of bug fixes and first attempt at generating an actual typescript file. Lots of bugs to squash still