fixes for terminate