Cleaned up and improved the de-ghosting code.