Fix some bugs; add unsupervised training; and improve code;