Changed service lifecycle and fixed related bugs.