Fixes to the classification algorithim