Full HA script refactoring

final full ha version