Fix class variable bugs; Move bridge control code to the end.