SN-89 Implement group rest and logic. Fix bugs and refactor