Fixed Seg fault in learn mode.