Separated code into classes. Optimized some things. Added better scoring.