Fixed some bugs for BZ#1013886