fix several bugs, fix ir input