Added termination call and fixed issue #32 and #24