use lambda instead of  small function
clean up signal handling
fix ua overriding logic