Fix bugs in helper