Cleaned up logic for local name completion.