refactoring and thread simplification; RL in progress