C pointer issues

Improper use of ctypes function restype resulted in negative pointer addresses due to truncation of long values. Proper way of implementing custom ctypes return types involved also implementing errcheck function.