changed all handles to IntPtr