Fixes for various problems discovered when doing a full compile