diff --git a/.travis.yml b/.travis.yml
index f408a01..07496e8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,9 +5,6 @@ php:
    - 5.6
    - nightly
 
-before_script:
-   - rm build/index.php
-   - php rebuild_module_index.php
-   - php build.php
+before_script: php build.php
 
 script: php -l build/index.php
diff --git a/build.bat b/build.bat
index 9c3b059..5e8680b 100644
--- a/build.bat
+++ b/build.bat
@@ -1,5 +1,2 @@
 @echo off
-echo Deleting old index.php
-del build\index.php
-php rebuild_module_index.php
-php build.php 
+php build.php
diff --git a/build.php b/build.php
index 798cf9f..b5cb15f 100644
--- a/build.php
+++ b/build.php
@@ -1,79 +1,54 @@
-<?php
-
-if(php_sapi_name() == "cli")
-{
-	echo("Beginning build...\n");
-	echo("Reading in module index...\n");
-}
-
-$module_index = json_decode(file_get_contents("module_index.json"));
-$module_list = [];
-foreach($module_index as $module)
-{
-	$module_list[] = $module->id;
-}
-
-if(isset($_GET["modules"]))
-{
-	$module_list = explode(",", $_GET["modules"]);
-}
-
-if(php_sapi_name() != "cli")
-{
-	header("content-type: text/php");
-}
-
-if(php_sapi_name() == "cli") echo("Reading in core files...");
-
-$core = file_get_contents("core.php");
-$settings = file_get_contents("settings.fragment.php");
-$settings = str_replace([ "<?php", "?>" ], "", $settings);
-$core = str_replace("{settings}", $settings, $core);
-
-$result = $core;
-
-foreach($module_list as $module_id)
-{
-	if($module_id == "") continue;
-	
-	if(php_sapi_name() == "cli") echo("Adding $module_id\n");
-	
-	$module_filepath = "modules/" . preg_replace("[^a-zA-Z0-9\-]", "", $module_id) . ".php";
-	
-	//echo("id: $module_id | filepath: $module_filepath\n");
-	
-	if(!file_exists($module_filepath))
-	{
-		http_response_code(400);
-		exit("Failed to load module with name: $module_filepath");
-	}
-	
-	$modulecode = file_get_contents($module_filepath);
-	$modulecode = str_replace([ "<?php", "?>" ], "", $modulecode);
-	$result = str_replace(
-		"// %next_module% //",
-		"$modulecode\n// %next_module% //",
-		$result);
-}
-
-if(php_sapi_name() == "cli")
-{
-	if(file_exists("build/index.php"))
-	{
-		echo("index.php already exists in the build folder, exiting\n");
-		exit(1);
-	}
-	else
-	{
-		echo("Done. Saving to disk...");
-		file_put_contents("build/index.php", $result);
-		echo("complete!\n");
-		echo("*** Build Completed ***\n");
-	}
-}
-else
-{
-	exit($result);
-}
-
-?>
+<?php
+
+echo("*** Preparing environment ***\n");
+
+$build_env = new stdClass();
+$build_env->target = "build/index.php";
+
+if(file_exists($build_env->target))
+{
+	echo("Deleting old target...\n");
+	unlink($build_env->target);
+}
+
+//////////////////////////////////////////////////////////////////////
+//////////////////////// Rebuild Module Index ////////////////////////
+//////////////////////////////////////////////////////////////////////
+
+echo("*** Rebuilding module index ***\n");
+$modules = glob("modules/*.php");
+$module_index = [];
+
+function register_module($settings)
+{
+	global $module_index;
+	$newmodule = [
+		"name" => $settings["name"],
+		"version" => $settings["version"],
+		"author" => $settings["author"],
+		"description" => $settings["description"],
+		"id" => $settings["id"],
+		"lastupdate" => filemtime("modules/" . $settings["id"] . ".php")
+	];
+	$module_index[] = $newmodule;
+}
+
+foreach($modules as $filename)
+{
+	echo("Processing $filename\n");
+	require($filename);
+}
+
+echo("*** Processing complete ***\n");
+
+echo("Writing new module index to disk...");
+file_put_contents("module_index.json", json_encode($module_index, JSON_PRETTY_PRINT));
+echo("done\n");
+
+
+//////////////////////////////////////////////////////////////////////
+////////////////////////// Build New Target //////////////////////////
+//////////////////////////////////////////////////////////////////////
+require("pack.php");
+
+?>
diff --git a/build.sh b/build.sh
index b150970..7e3efad 100644
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,2 @@
 #!/usr/bin/env bash
-echo Deleting old index.php
-rm build/index.php
-php rebuild_module_index.php
 php build.php
diff --git a/download.php b/download.php
index e20cf30..65e76f6 100644
--- a/download.php
+++ b/download.php
@@ -76,7 +76,7 @@
 			
 			function download()
 			{
-				var url = "build.php?web=true&modules=",
+				var url = "pack.php?web=true&modules=",
 					checkboxes = document.querySelectorAll("input[type=checkbox]");
 				for(var i = 0; i < checkboxes.length; i++)
 				{
diff --git a/pack.php b/pack.php
new file mode 100644
index 0000000..b5506bc
--- /dev/null
+++ b/pack.php
@@ -0,0 +1,79 @@
+<?php
+
+if(php_sapi_name() == "cli")
+{
+	echo("*** Beginning main build sequence ***\n");
+	echo("Reading in module index...\n");
+}
+
+$module_index = json_decode(file_get_contents("module_index.json"));
+$module_list = [];
+foreach($module_index as $module)
+{
+	$module_list[] = $module->id;
+}
+
+if(isset($_GET["modules"]))
+{
+	$module_list = explode(",", $_GET["modules"]);
+}
+
+if(php_sapi_name() != "cli")
+{
+	header("content-type: text/php");
+}
+
+if(php_sapi_name() == "cli") echo("Reading in core files...");
+
+$core = file_get_contents("core.php");
+$settings = file_get_contents("settings.fragment.php");
+$settings = str_replace([ "<?php", "?>" ], "", $settings);
+$core = str_replace("{settings}", $settings, $core);
+
+$result = $core;
+
+foreach($module_list as $module_id)
+{
+	if($module_id == "") continue;
+	
+	if(php_sapi_name() == "cli") echo("Adding $module_id\n");
+	
+	$module_filepath = "modules/" . preg_replace("[^a-zA-Z0-9\-]", "", $module_id) . ".php";
+	
+	//echo("id: $module_id | filepath: $module_filepath\n");
+	
+	if(!file_exists($module_filepath))
+	{
+		http_response_code(400);
+		exit("Failed to load module with name: $module_filepath");
+	}
+	
+	$modulecode = file_get_contents($module_filepath);
+	$modulecode = str_replace([ "<?php", "?>" ], "", $modulecode);
+	$result = str_replace(
+		"// %next_module% //",
+		"$modulecode\n// %next_module% //",
+		$result);
+}
+
+if(php_sapi_name() == "cli")
+{
+	if(file_exists("build/index.php"))
+	{
+		echo("index.php already exists in the build folder, exiting\n");
+		exit(1);
+	}
+	else
+	{
+		echo("Done. Saving to disk...");
+		file_put_contents("build/index.php", $result);
+		echo("complete!\n");
+		echo("*** Build completed! ***\n");
+	}
+}
+else
+{
+	exit($result);
+}
+
+?>
diff --git a/rebuild_module_index.php b/rebuild_module_index.php
deleted file mode 100644
index 19bf2b5..0000000
--- a/rebuild_module_index.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-echo("Rebuilding module index...\n");
-$modules = glob("modules/*.php");
-$module_index = [];
-
-function register_module($settings)
-{
-	global $module_index;
-	$newmodule = [
-		"name" => $settings["name"],
-		"version" => $settings["version"],
-		"author" => $settings["author"],
-		"description" => $settings["description"],
-		"id" => $settings["id"],
-		"lastupdate" => filemtime("modules/" . $settings["id"] . ".php")
-	];
-	$module_index[] = $newmodule;
-}
-
-foreach($modules as $filename)
-{
-	echo("Processing $filename\n");
-	require($filename);
-}
-
-echo("*** Processing Complete ***\n");
-
-echo("Writing new module index to disk...");
-file_put_contents("module_index.json", json_encode($module_index, JSON_PRETTY_PRINT));
-echo("done\n");
-
-?>
