Major rewrite, speed improved, scores are wrong