Fix some connection bugs and add more regex.