fix call stack overflow and ui issues