cleanup code and fix single group display bug