Calculate pointer dependencies correctly, and linearise function space sorts