Fix a bunch of stuff and add missing docs