Add a bunch of missing files, fix a bug