Code cleanup + added win/lose conditions