Miscellaneous fixes

Miscellaneous fixes