More type and misc fixes