fixed some bugs and improved training