WIP: various updates

I'm working on adding some more type check features here. Feel free to cherry-pick stuff along the way, since I'm not entirely sure how this will evolve.