Added more initializations and terminations