refactor and stabilization