More thorough error checking on library calls.