Adding supervised learning, and improving code quality