diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ff81e153..59cfe4ea3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,6 +21,7 @@ function(createDefaultCacheConfig)
 	set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)")
 	set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.")
 	set(JUSTTESTS OFF CACHE BOOL "Build only for tests.")
+	set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)")
 endfunction()
 
 
@@ -50,6 +51,10 @@ function(configureProject)
 		add_definitions(-DETH_FATDB)
 	endif()
 
+	if (SOLIDITY)
+		add_definitions(-DETH_SOLIDITY)
+	endif()
+
 	if (HEADLESS OR JUSTTESTS)
 		add_definitions(-DETH_HEADLESS)
 	endif()
diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp
index c62a00f88..121af1b59 100644
--- a/libethereum/Precompiled.cpp
+++ b/libethereum/Precompiled.cpp
@@ -83,10 +83,10 @@ static bytes identityCode(bytesConstRef _in)
 
 static const std::map<unsigned, PrecompiledAddress> c_precompiled =
 {
-	{ 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }},
-	{ 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }},
-	{ 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }},
-	{ 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }}
+	{ 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }},
+	{ 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }},
+	{ 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }},
+	{ 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }}
 };
 
 std::map<unsigned, PrecompiledAddress> const& dev::eth::precompiled()
diff --git a/test/trie.cpp b/test/trie.cpp
index 84d0e846f..9e59dd316 100644
--- a/test/trie.cpp
+++ b/test/trie.cpp
@@ -74,6 +74,68 @@ BOOST_AUTO_TEST_CASE(fat_trie)
 	}
 }
 
+BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test)
+{
+	string testPath = test::getTestPath();
+
+	testPath += "/TrieTests";
+
+	cnote << "Testing Secure Trie...";
+	js::mValue v;
+	string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json"));
+	BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?");
+	js::read_string(s, v);
+	for (auto& i: v.get_obj())
+	{
+		cnote << i.first;
+		js::mObject& o = i.second.get_obj();
+		vector<pair<string, string>> ss;
+		for (auto i: o["in"].get_obj())
+		{
+			ss.push_back(make_pair(i.first, i.second.get_str()));
+			if (!ss.back().first.find("0x"))
+				ss.back().first = asString(fromHex(ss.back().first.substr(2)));
+			if (!ss.back().second.find("0x"))
+				ss.back().second = asString(fromHex(ss.back().second.substr(2)));
+		}
+		for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j)
+		{
+			next_permutation(ss.begin(), ss.end());
+			MemoryDB m;
+			GenericTrieDB<MemoryDB> t(&m);
+			MemoryDB hm;
+			HashedGenericTrieDB<MemoryDB> ht(&hm);
+			MemoryDB fm;
+			FatGenericTrieDB<MemoryDB> ft(&fm);
+			t.init();
+			ht.init();
+			ft.init();
+			BOOST_REQUIRE(t.check(true));
+			BOOST_REQUIRE(ht.check(true));
+			BOOST_REQUIRE(ft.check(true));
+			for (auto const& k: ss)
+			{
+				t.insert(k.first, k.second);
+				ht.insert(k.first, k.second);
+				ft.insert(k.first, k.second);
+				BOOST_REQUIRE(t.check(true));
+				BOOST_REQUIRE(ht.check(true));
+				BOOST_REQUIRE(ft.check(true));
+				for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j)
+				{
+					BOOST_CHECK_EQUAL(i == ft.end(), j == t.end());
+					BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes());
+					BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes());
+				}
+				BOOST_CHECK_EQUAL(ht.root(), ft.root());
+			}
+			BOOST_REQUIRE(!o["root"].is_null());
+			BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray()));
+			BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray()));
+		}
+	}
+}
+
 BOOST_AUTO_TEST_CASE(trie_test_anyorder)
 {
 	string testPath = test::getTestPath();