Is there a way to optimize out some foreign calls?