terminate() and other small changes