Some fixes and a bunch of TODOs.