Improved Inference For Spatial And Panel Models