Rework training, simplify input data extraction, add comments.