fix a few miscellaneous bugs