private void updateLevelButtons() {
    	int y = 0;
    	
    	// Remove previous buttons
    	if (levelButtons != null) {
            for (int i = 0; i < levelButtons.length; i++) {
                if (levelButtons[i] != null) {
                    removeButton(levelButtons[i]);
                }
            }
    	}
    	
    	// Create level buttons
        levelButtons = new LevelButton[Math.min(LEVELS_PER_PAGE,
                levels.size() - currentPage * LEVELS_PER_PAGE)];
    	for (int i = currentPage * LEVELS_PER_PAGE;
    	         i < Math.min((currentPage + 1) * LEVELS_PER_PAGE, levels.size());
    	         i++) {
    		int x = i % xButtons;
    		int buttonIndex = i % LEVELS_PER_PAGE;
    		
    		levelButtons[buttonIndex] = (LevelButton) addButton(new LevelButton(i, levels.get(i), 
    		        xStart + x * xSpacing, yStart + ySpacing * y));
    		if (buttonIndex == 0) {
    			activeButton = levelButtons[buttonIndex];
    			activeButton.setActive(true);
    		}
    
    		if (x == (xButtons - 1)) {
    			y++;
    		}
    	}
    }