Added timeout options; Improved leak avoidance