Detailed SMO algorithm