miscellaneous bug fixing