added get last error and changed packing of struct