Massive refactoring plus addition of logit/ unrunnable