fix a bug and work around another one