Cleaned up some P/Invoke code