releasing lock earlier on newdata change
fixed error checking after wait in get/put
fixed macro pointer casts