Encontre todos os bugs desse código, corrija-os, e aprimore o código.

```
import pygame
import random

# Initialize Pygame
pygame.init()

# Define the screen dimensions
screen_width = 800
screen_height = 600
snake_block_size = 10
snake_speed = 20

# Colors
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
green = (0, 255, 0)

# Set up the display
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption('Snake Game')

# Clock for frame rate
clock = pygame.time.Clock()

def gameLoop():
    game_over = False
    game_close = False

    # Initial position of the snake and its speed
    x1 = screen_width // 2
    y1 = screen_height // 2
    x1_change = 0
    y1_change = 0
    direction = 'RIGHT'

    # List to store the body segments of the snake
    snake_body = []
    snake_length = 1

    # Game over message
    game_over_message = "Game Over"

    # Main game loop
    while not game_over:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                game_close = True
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_LEFT:
                    x1_change = -snake_block_size
                    y1_change = 0
                    direction = 'LEFT'
                elif event.key == pygame.K_RIGHT:
                    x1_change = snake_block_size
                    y1_change = 0
                    direction = 'RIGHT'
                elif event.key == pygame.K_UP:
                    y1_change = -snake_block_size
                    x1_change = 0
                    direction = 'UP'
                elif event.key == pygame.K_DOWN:
                    y1_change = snake_block_size
                    x1_change = 0
                    direction = 'DOWN'

        # Update the snake's position based on direction
        if direction == 'LEFT':
            x1 -= snake_block_size
        elif direction == 'RIGHT':
            x1 += snake_block_size
        elif direction == 'UP':
            y1 -= snake_block_size
        elif direction == 'DOWN':
            y1 += snake_block_size

        # Check for collision with the walls or itself
        if x1 >= screen_width or x1 < 0 or y1 >= screen_height or y1 < 0:
            game_close = True
        if x1 in snake_body:
            game_close = True

        # Add a new segment to the snake body
        snake_body.append((x1, y1))

        # Remove the tail of the snake body when it is eaten
        if len(snake_body) > snake_length:
            del snake_body[0]

        # Clear the screen and draw the snake
        screen.fill(white)
        for x in snake_body:
            pygame.draw.rect(screen, black, [x[0], x[1], snake_block_size, snake_block_size])

        # Draw the food if it exists
        if len(snake_body) > 2:
            food_x = random.randint(0, screen_width - snake_block_size)
            food_y = random.randint(0, screen_height - snake_block_size)
            pygame.draw.rect(screen, green, [food_x, food_y, snake_block_size, snake_block_size])

        # Display game over message if game is over
        if game_close:
            game_over_message = "Game Over"
            pygame.display.set_caption("Snake Game")
            score_text = f"Score: {snake_length}"
            font = pygame.font.SysFont(None, 36)
            score_surface = font.render(score_text, True, black)
            screen.blit(score_surface, [screen_width // 2 - score_surface.get_width() // 2, screen_height // 4])

        # Update the display
        pygame.display.flip()

        # Cap the frame rate
        clock.tick(snake_speed)

    pygame.quit()
    quit()

if __name__ == "__main__":
    gameLoop()
```