Fix some (but not all) bugs