switch to jna
use intbyreference instead of buffer
change type of opaque structs to typed poitners as zero length structs is not allowed.