Refactored for easier reading
Clean up code, decline some invalid moves.