small optimizations in listener code generator