Replaced pInvokes with Unity methods.