fixed various bugs, added training/testing sets