Debug removed & some refactoring.