Fix some XHP-related type errors
Handle non-existant directories properly