Fixed problem with top_score in stats and optimized the queries and function.