added weight to categorized training. Some improvements.