diff --git a/characterprofile.php b/characterprofile.php
index cec8686..722a5ce 100644
--- a/characterprofile.php
+++ b/characterprofile.php
@@ -29,7 +29,6 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false)
 		}
 		
 		$profile_znote_data = user_znote_character_data($user_id, 'created', 'hide_char', 'comment');
-		$account_data = user_znote_account_data($profile_data['account_id'], 'flag');
 		
 		$guild_exist = false;
 		
@@ -47,12 +46,18 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false)
 		<!-- Profile name -->
 		<h1><font class="profile_font" name="profile_font_header">Profile: <?php echo $profile_data['name']; ?></font></h1>
 			<ul class="unstyled">
-				<?php 
-				if ($config['country_flags'])
-				{ ?>
-					<!-- Player country data -->
-					<li><font class="profile_font" name="profile_font_country">Country: <?php echo '<img src="flags/' . $account_data['flag'] . '.png">'; ?></font></li><?php
-				} ?>
+				<?php
+				$flags = $config['country_flags'];
+				if ($flags['enabled'] && $flags['characterprofile']) { 
+					$account_data = user_znote_account_data($profile_data['account_id'], 'flag');
+
+					if (strlen($account_data['flag']) > 0):
+						?><!-- Player country data -->
+						<li><font class="profile_font" name="profile_font_country">Country: <?php echo '<img src="' . $flags['server'] . '/' . $account_data['flag'] . '.png">'; ?></font></li>
+						<?php
+					endif;
+				}
+				?>
 				
 				<!-- Player Position -->
 				<?php if ($profile_data['group_id'] > 1) { ?>
diff --git a/config.php b/config.php
index cf3f74c..a42cb16 100644
--- a/config.php
+++ b/config.php
@@ -560,7 +560,13 @@
 	$config['use_guild_logos'] = true;
 	
 	// Use country flags
-	$config['country_flags'] = false;
+	$config['country_flags'] = array(
+		'enabled' => true,
+		'highscores' => true,
+		'onlinelist' => true,
+		'characterprofile' => true,
+		'server' => 'http://flag.znote.eu'
+	);
 
 	// Level requirement to create guild? (Just set it to 1 to allow all levels).
 	$config['create_guild_level'] = 8;
diff --git a/engine/function/general.php b/engine/function/general.php
index f781c15..de9c7a4 100644
--- a/engine/function/general.php
+++ b/engine/function/general.php
@@ -277,13 +277,6 @@ function format_character_name($name) {
 	return ucwords(strtolower($name));
 }
 
-// Returns a list of players online
-function online_list() {
-	if (config('TFSVersion') == 'TFS_10') return mysql_select_multi("SELECT `o`.`player_id` AS `id`, `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname` FROM `players_online` as `o` INNER JOIN `players` as `p` ON `o`.`player_id` = `p`.`id` LEFT JOIN `guild_membership` gm ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` g ON `gm`.`guild_id` = `g`.`id`");
-	else return mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname` FROM `players` p LEFT JOIN `guild_ranks` gr ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;");
-}
-
-
 // Gets you the actual IP address even from users behind ISP proxies and so on.
 function getIP() {
 	/*
diff --git a/highscores.php b/highscores.php
index f3a6bbd..bc64e56 100644
--- a/highscores.php
+++ b/highscores.php
@@ -28,6 +28,7 @@ if (!$page || $page == 0) $page = 1;
 else $page = (int)$page;
 
 $highscore = $config['highscore'];
+$loadFlags = ($config['country_flags']['enabled'] && $config['country_flags']['highscores']) ? true : false;
 
 $rows = $highscore['rows'];
 $rowsPerPage = $highscore['rowsPerPage'];
@@ -53,7 +54,7 @@ function pageCheck($index, $page, $rowPerPage) {
 
 $cache = new Cache('engine/cache/highscores');
 if ($cache->hasExpired()) {
-	$vocGroups = fetchAllScores($rows, $config['TFSVersion'], $highscore['ignoreGroupId'], $configVocations, $vocation, $config['country_flags']);
+	$vocGroups = fetchAllScores($rows, $config['TFSVersion'], $highscore['ignoreGroupId'], $configVocations, $vocation, $loadFlags);
 	
 	$cache->setContent($vocGroups);
 	$cache->save();
@@ -128,7 +129,7 @@ if ($vocGroups) {
 				<?php
 			} else {
 				if (pageCheck($i, $page, $rowsPerPage)) {
-					$flag = ($config['country_flags'] === true && strlen($vocGroup[$type][$i]['flag']) > 1) ? '<img src="flags/' . $vocGroup[$type][$i]['flag'] . '.png">  ' : '';
+					$flag = ($loadFlags === true && strlen($vocGroup[$type][$i]['flag']) > 1) ? '<img src="' . $config['country_flags']['server'] . '/' . $vocGroup[$type][$i]['flag'] . '.png">  ' : '';
 					?>
 					<tr>
 						<td><?php echo $i+1; ?></td>
diff --git a/onlinelist.php b/onlinelist.php
index d2a8cf3..348b4cb 100644
--- a/onlinelist.php
+++ b/onlinelist.php
@@ -2,8 +2,30 @@
 
 <h1>Who is online?</h1>
 <?php
-$array = online_list();
-if ($array) {
+
+// Returns a list of players online
+$array = false;
+$loadFlags = ($config['country_flags']['enabled'] && $config['country_flags']['onlinelist']) ? true : false;
+
+// Small 30 seconds players_online cache. 
+$cache = new Cache('engine/cache/onlinelist');
+$cache->setExpiration(30);
+if ($cache->hasExpired()) {
+	// Load online list data from SQL
+	if ($config['TFSVersion'] == 'TFS_10') {
+		$array = ($loadFlags === true) ? mysql_select_multi("SELECT `p`.`name` AS `name`, `p`.`level` AS `level`, `p`.`vocation` AS `vocation`, `g`.`name` AS `gname`, `za`.`flag` AS `flag` FROM `players_online` AS `o` INNER JOIN `players` AS `p` ON `o`.`player_id` = `p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id` = `za`.`account_id` LEFT JOIN `guild_membership` AS `gm` ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` AS `g` ON `gm`.`guild_id` = `g`.`id`;") : mysql_select_multi("SELECT `p`.`name` AS `name`, `p`.`level` AS `level`, `p`.`vocation` AS `vocation`, `g`.`name` AS `gname` FROM `players_online` AS `o` INNER JOIN `players` AS `p` ON `o`.`player_id` = `p`.`id` LEFT JOIN `guild_membership` AS `gm` ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` AS `g` ON `gm`.`guild_id` = `g`.`id`;");
+	} else {
+		$array = ($loadFlags === true) ? mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname`, `za`.`flag` as `flag` FROM `players` as `p` INNER JOIN `znote_accounts` as `za` ON `za`.`account_id` = `p`.`account_id` LEFT JOIN `guild_ranks` as `gr` ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` as `g` ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;") : mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname` FROM `players` as `p` LEFT JOIN `guild_ranks` as `gr` ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` as `g` ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;");
+	}
+	// End loading data from SQL
+	$cache->setContent($array);
+	$cache->save();
+} else {
+	$array = $cache->load();
+}
+// End cache
+
+if ($array !== false) {
 	?>
 	
 	<table id="onlinelistTable" class="table table-striped table-hover">
@@ -13,17 +35,21 @@ if ($array) {
 			<th>Level:</th>
 			<th>Vocation:</th>
 		</tr>
-			<?php
-			foreach ($array as $value) {
+		<?php
+		foreach ($array as $value) {
 			$url = url("characterprofile.php?name=". $value['name']);
-			echo '<tr class="special" onclick="javascript:window.location.href=\'' . $url . '\'">';
-			echo '<td><a href="characterprofile.php?name='. $value['name'] .'">'. $value['name'] .'</a></td>';
-			if (!empty($value['gname'])) echo '<td><a href="guilds.php?name='. $value['gname'] .'">'. $value['gname'] .'</a></td>'; else echo '<td></td>'; 
-			echo '<td>'. $value['level'] .'</td>';
-			echo '<td>'. vocation_id_to_name($value['vocation']) .'</td>';
-			echo '</tr>';
-			}
+			$flag = ($loadFlags === true && strlen($value['flag']) > 1) ? '<img src="' . $config['country_flags']['server'] . '/' . $value['flag'] . '.png">  ' : '';
+			$guildname = (!empty($value['gname'])) ? '<a href="guilds.php?name='. $value['gname'] .'">'. $value['gname'] .'</a>' : '';
 			?>
+			<tr class="special" onclick="javascript:window.location.href='<?php echo $url; ?>'">
+				<td><?php echo $flag; ?><a href="characterprofile.php?name=<?php echo $value['name']; ?>"><?php echo $value['name']; ?></a></td>
+				<td><?php echo $guildname; ?></td>
+				<td><?php echo $value['level']; ?></td>
+				<td><?php echo vocation_id_to_name($value['vocation']); ?></td>
+			</tr>
+			<?php
+		}
+		?>
 	</table>
 
 	<?php