Moved some stuff into global init/terminate method