@@IDENTITY in line 382 should be replaced with SCOPE_IDENTITY(), as @@IDENTITY is an unreliable way of returning an IDENTITY key from newly inserted row. @@IDENTITY can cause subtle bugs, especially in a case where triggers are used. http://blogs.msdn.com/b/spike/archive/2009/10/20/my-take-on-identity-vs-scope-identity.aspx
It appears that this issue has been submitted before.
You can change as needed. Going to keep in place for SQL CE support...