Miscellaneous bug fix