improved startup and shutdown