Misc Fixes

Misc fixes to remove runtime errors.