diff --git a/.gitignore b/.gitignore
index cd07471f9afa049f8f63f30ebe75500d7510163d..64c48e5136c01e5d365741b280d591049e18d004 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
 /logo/*.png
 /fanart/*.jpg
 /poster/*.jpg
+/cache/*.json
diff --git a/api.php b/api.php
index 7963532771815275620c097973e1e3d71c3aa37a..824929a57a25da2dfd7244c443afc185c158c2d0 100644
--- a/api.php
+++ b/api.php
@@ -3,21 +3,24 @@ include_once 'config.php';
 
 if ($_GET['get'] == 'shows' && $_GET['limit'] && isset($_GET['offset'])) {
 
-	$sbdb = new PDO('sqlite:'.$sbPath.'/sickbeard.db');
-
-	$shows = $sbdb->query("SELECT tvdb_id AS id, show_name AS name, location FROM tv_shows ORDER BY show_name ASC LIMIT ".$_GET['limit']." OFFSET ".$_GET['offset'].";");
 	$output = array();
-	foreach($shows as $show) {
-		$rows = $sbdb->query("SELECT season, COUNT(episode_id) AS count FROM tv_episodes WHERE showid = '".$show['id']."' GROUP BY season ORDER BY season ASC");
+	$data = querySB('shows');
+	uasort($data, function($a, $b) {
+		return strcmp($a['show_name'], $b['show_name']);
+	});
+	$shows = array_slice($data, $_GET['offset'], $_GET['limit'], true);
+	foreach($shows as $key => $show) {
+		$dataShow = querySB('show', $key);		
+		$dataSeasons = querySB('show.seasons', $key);
 		$seasons = array();
-		foreach($rows as $row) {
-			array_push($seasons, array("season" => $row['season'], "count" => $row['count']));
+		foreach($dataSeasons as $season => $episodes) {
+			array_push($seasons, array("season" => $season, "count" => count($episodes)));
 		}
 		array_push($output, array(
-			"id" => $show['id'],
-			"name" => $show['name'],
-			"folder" => str_replace($showsPath.'/', '', $show['location']),
-			"thumb" => cleanName($show['name']),
+			"id" => $key,
+			"name" => $show['show_name'],
+			"folder" => str_replace($showsPath.'/', '', $dataShow['location']),
+			"thumb" => cleanName($show['show_name']),
 			"seasons" => $seasons
 		));
 		unset($seasons);
@@ -170,13 +173,12 @@ if ($_GET['get'] == 'logo' && (!empty($_GET['show']) || !empty($_GET['movie'])))
 
 
 if ($_GET['get'] == 'episodes' && !empty($_GET['show']) && isset($_GET['season'])) {
-	$sbdb = new PDO('sqlite:'.$sbPath.'/sickbeard.db');
-	$episodes = $sbdb->query("SELECT episode, name, airdate, status FROM tv_episodes WHERE showid = '".$_GET['show']."' AND season = '".$_GET['season']."' ORDER BY episode ASC;");
 	$output = array();
-	foreach ($episodes as $episode) {
-		$date = new DateTime('0001-01-00');
-		$date->add(new DateInterval('P'.$episode['airdate'].'D'));
-		array_push($output, array("episode" => $episode['episode'], "name" => $episode['name'], "status" => (string)$episode['status'], "airdate" => $date->format('Y-m-d')));
+	if($json = file_get_contents('http://'.$sb['host'].':'.$sb['port'].$sb['path'].'/api/'.$sb['key'].'/?cmd=show.seasons&tvdbid='.$_GET['show'].'&season='.$_GET['season'])) {
+		$data = current(json_decode($json, true));
+		foreach ($data as $key => $episode) {
+			array_push($output, array("episode" => $key, "name" => $episode['name'], "status" => $episode['status'], "airdate" => $episode['airdate']));
+		}
 	}
 	echo json_encode($output);
 	die;
@@ -184,14 +186,16 @@ if ($_GET['get'] == 'episodes' && !empty($_GET['show']) && isset($_GET['season']
 
 
 if ($_GET['get'] == 'latest' && $_GET['type'] == 'shows') {
-	$sbdb = new PDO('sqlite:'.$sbPath.'/sickbeard.db');
-	$eps = $sbdb->query("SELECT s.show_name, ep.name, ep.episode, ep.season, ep.airdate FROM tv_episodes AS ep JOIN tv_shows AS s ON ep.showid=s.tvdb_id WHERE ep.status LIKE '%4' ORDER BY ep.airdate DESC LIMIT 10;");
+	
+	//$eps = $sbdb->query("SELECT s.show_name, ep.name, ep.episode, ep.season, ep.airdate FROM tv_episodes AS ep JOIN tv_shows AS s ON ep.showid=s.tvdb_id WHERE ep.status LIKE '%4' ORDER BY ep.airdate DESC LIMIT 10;");
+	$eps = querySB('history');
 	$output = array();
 	foreach ($eps as $ep) {
-		$date = new DateTime('0001-01-00');
-		$date->add(new DateInterval('P'.$ep['airdate'].'D'));
-		array_push($output, array("show" => $ep['show_name'], "episode" => "S".str_pad($ep['season'], 2, '0', STR_PAD_LEFT)."E".str_pad($ep['episode'], 2, '0', STR_PAD_LEFT), "name" => $ep['name'], "airdate" => $date->format('Y-m-d')));
+		if($ep['status'] == 'Downloaded') {
+			array_push($output, array("show" => $ep['show_name'], "episode" => "S".str_pad($ep['season'], 2, '0', STR_PAD_LEFT)."E".str_pad($ep['episode'], 2, '0', STR_PAD_LEFT), "airdate" => $ep['date']));
+		}
 	}
+	$output = array_slice($output, 0, 10);
 	echo json_encode($output);
 	die;
 }
@@ -237,4 +241,19 @@ function get_absolute_path($path) {
 	return implode(DIRECTORY_SEPARATOR, $absolutes);
 }
 
+function querySB($cmd, $id = '', $season = '') {
+	global $sb, $cacheTTL;
+	if($id == '') {
+		$cache = './cache/'.$cmd.'.json';
+	}else{
+		$cache = './cache/'.$cmd.'-'.$id.'.json';
+	}
+	if (!file_exists($cache) || filemtime($cache) < time()-$cacheTTL) {
+		file_put_contents($cache, file_get_contents('http://'.$sb['host'].':'.$sb['port'].$sb['path'].'/api/'.$sb['key'].'/?cmd='.$cmd.'&tvdbid='.$id.'&season='.$season));
+	}
+	$json = file_get_contents($cache);
+	$data = current(json_decode($json, true));
+	return $data;
+}
+
 ?>
\ No newline at end of file
diff --git a/cache/dummy b/cache/dummy
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/config.php-dist b/config.php-dist
index de1b5f0d34700801174e4bc769ddb87887136901..8e08ddfa99eb4b0729b8111e76d76776ca6fc596 100644
--- a/config.php-dist
+++ b/config.php-dist
@@ -1,9 +1,16 @@
 <?php
 
-$sbPath = '/opt/sickbeard';
-$cpPath = '/opt/sickbeard';
+$cpPath = '/opt/couchpotato';
+
+$sb['host'] = 'localhost';
+$sb['post'] = '8080';
+$sb['path'] = '/';
+$sb['key'] = 'YOUR-SICKBEARD-API-KEY';
+$sb['ssl'] = false;
 
 $showsPath = '/mnt/storage/media/tv';
 $moviesPath = '/mnt/storage/media/movies';
 
+$cacheTTL = 3600;
+
 ?>
\ No newline at end of file
diff --git a/css/mediarack.css b/css/mediarack.css
index b32c49007359d2ab752074e24462fc41d09cfd2a..3a72b0886969c105af291a8483e29f0ae6069d18 100644
--- a/css/mediarack.css
+++ b/css/mediarack.css
@@ -88,6 +88,10 @@ div.epLabel {
 
 }
 
+#loading {
+	display: none;
+}
+
 .jcarousel-wrapper {
     margin: 20px auto;
     position: relative;
diff --git a/img/loading.gif b/img/loading.gif
new file mode 100644
index 0000000000000000000000000000000000000000..d6485b28a7030275420738bcf0907d2c2a784603
Binary files /dev/null and b/img/loading.gif differ
diff --git a/img/loading_dark.gif b/img/loading_dark.gif
new file mode 100644
index 0000000000000000000000000000000000000000..3cea7541a77df0ccab6a714c09335f97451a98bc
Binary files /dev/null and b/img/loading_dark.gif differ
diff --git a/index.php b/index.php
index 62214551391b2605df7f2d92091d1b682c49a055..421260aa2d3f80903c03e4fc7c548e06214ba432 100644
--- a/index.php
+++ b/index.php
@@ -55,7 +55,7 @@
     </div>
 
     <div class="container">
-
+	
 		<div class="content" id="home">
 			<div class="panel panel-default">
 				<div class="panel-heading">
@@ -90,6 +90,15 @@
 		<div class="content" id="shows"></div>
 
 		<div class="content" id="movies"></div>
+		
+		<div class="panel panel-default" id="loading">
+			<div class="panel-heading text-center">
+				<img src="img/loading.gif" alt="Loading..." />
+			</div>
+			<div class="panel-body text-center">
+				<img src="img/loading_dark.gif" alt="Loading..." />
+			</div>
+		</div>
 
     </div> <!-- /container -->
 
diff --git a/js/mediarack.js b/js/mediarack.js
index 400c0c2ac666f540b78ee0d941475594f2a1bfa0..139da29b1fea8b50f07db236df1452cbd258c799 100644
--- a/js/mediarack.js
+++ b/js/mediarack.js
@@ -58,7 +58,7 @@ function getLatest(type) {
 			$.each(data, function (key, ep) {
 				var ulLatestContainer = $("#latest"+type);
 				if(type == 'Shows') {
-					var liLatestItem =  $('<li><img src="api.php?get=poster&show='+escape(ep.show)+'" /><div class="epLabel">'+ep.show+'<br />'+ep.episode+'<br />'+ep.name+'<br />'+ep.airdate+'</div></li>');
+					var liLatestItem =  $('<li><img src="api.php?get=poster&show='+escape(ep.show)+'" /><div class="epLabel">'+ep.show+'<br />'+ep.episode+'<br />'+ep.airdate+'</div></li>');
 				}else{
 					var liLatestItem =  $('<li><img src="api.php?get=poster&movie='+escape(ep.movie)+'" /><div class="epLabel">'+ep.movie+'</div></li>');
 				}
@@ -110,6 +110,7 @@ function getLatest(type) {
 }
 
 function getShows() {
+	$("#loading").show();
 	$.getJSON('api.php', {
 		'get': 'shows',
 		'limit': showLimit.toString(),
@@ -175,6 +176,7 @@ function getShows() {
 			if(i > 0) {
 				loadShows = true;
 			}
+			$("#loading").hide();
 		}
 	);
 }
@@ -189,22 +191,21 @@ function getEpisodes(show, season) {
 			liSeason.find("table.episodes").remove();
 			var olEpisodes = $('<table class="table table-bordered table-condensed episodes"></table>');
 			$.each(data, function (key, episode) {
-				console.log(episode.status.substr(-1, 1));
 				var status;
-				switch(episode.status.substr(-1, 1)) {
-					case '5': // ignored
+				switch(episode.status) {
+					case 'Ignored':
 						status = "info";
 						break;
-					case '4': // downloaded
+					case 'Downloaded':
 						status = "success";
 						break;
-					case '3': // wanted
+					case 'Wanted':
 						status = "danger";
 						break;
-					case '2': // snatched
+					case 'Snatched':
 						status = "warning";
 						break;
-					case '1': // unaired
+					case 'Unaired':
 						status = "";
 						break;
 					default: