moved pinvoke methods in to their own class as per MS code analysis suggestions