Added methods to write data into memory and reunlock the handle