Move files & update paths (#541)

* Move files & update paths

* Rename build to scripts.

* Fix paths

* Fix script.
diff --git a/.gitmodules b/.gitmodules
index e1e6cea..1e3e8a3 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,5 +1,5 @@
 [submodule "terryfy"]
-	path = terryfy
+	path = scripts/terryfy
 	url = https://github.com/MacPython/terryfy.git
 [submodule "research/esaxx"]
 	path = research/esaxx
diff --git a/.travis.yml b/.travis.yml
index 5466c8c..0737b44 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -250,17 +250,17 @@
 ###
 - if [ -n "${C_COMPILER}" ]; then export CC="${C_COMPILER}"; fi
 - if [ -n "${CXX_COMPILER}" ]; then export CXX="${CXX_COMPILER}"; fi
-- ./.travis.sh before_install
+- scripts/.travis.sh before_install
 install:
-- ./.travis.sh install
+- scripts/.travis.sh install
 script:
-- ./.travis.sh script
+- scripts/.travis.sh script
 after_success:
-- ./.travis.sh after_success
+- scripts/.travis.sh after_success
 
 before_deploy:
 - if [ "${BUILD_SYSTEM}" = "python" ] && [ "${TRAVIS_OS_NAME}" = "osx" ]; then export WHEELS=$(ls ./dist/*.whl); fi
-- ./.travis.sh before_deploy
+- scripts/.travis.sh before_deploy
 
 deploy:
 - provider: releases
@@ -273,7 +273,7 @@
     tags: true
     condition: "${BUILD_SYSTEM} = python && ${TRAVIS_OS_NAME} = osx"
 - provider: bintray
-  file: ".bintray.json"
+  file: "scripts/.bintray.json"
   user: "eustas"
   key:
     secure: "Kbam/lTAdz72fZivbs6riJT+Y4PbuKP7r6t5PAWxJxAAykjwnYTRe3zF472g9HCE14KYMsdB+KSYSgg6TGJnqGC9gL9xhhGU9U/WmA+vbMWS/MSnMWpK9IRpp77pM2i2NKZD4v33JuEwKFCBJP3Vj6QQ5Qd1NKdobuXJyznhgnw="
diff --git a/BUILD b/BUILD
index bc86186..789578f 100644
--- a/BUILD
+++ b/BUILD
@@ -25,44 +25,44 @@
 
 filegroup(
     name = "public_headers",
-    srcs = glob(["include/brotli/*.h"]),
+    srcs = glob(["c/include/brotli/*.h"]),
 )
 
 filegroup(
     name = "common_headers",
-    srcs = glob(["common/*.h"]),
+    srcs = glob(["c/common/*.h"]),
 )
 
 filegroup(
     name = "common_sources",
-    srcs = glob(["common/*.c"]),
+    srcs = glob(["c/common/*.c"]),
 )
 
 filegroup(
     name = "dec_headers",
-    srcs = glob(["dec/*.h"]),
+    srcs = glob(["c/dec/*.h"]),
 )
 
 filegroup(
     name = "dec_sources",
-    srcs = glob(["dec/*.c"]),
+    srcs = glob(["c/dec/*.c"]),
 )
 
 filegroup(
     name = "enc_headers",
-    srcs = glob(["enc/*.h"]),
+    srcs = glob(["c/enc/*.h"]),
 )
 
 filegroup(
     name = "enc_sources",
-    srcs = glob(["enc/*.c"]),
+    srcs = glob(["c/enc/*.c"]),
 )
 
 cc_library(
     name = "brotli",
     hdrs = [":public_headers"],
     copts = STRICT_C_OPTIONS,
-    includes = ["include"],
+    includes = ["c/include"],
 )
 
 cc_library(
@@ -92,7 +92,7 @@
 
 cc_binary(
     name = "bro",
-    srcs = ["tools/bro.c"],
+    srcs = ["c/tools/bro.c"],
     copts = STRICT_C_OPTIONS,
     linkstatic = 1,
     deps = [
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca612d1..ca54890 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -73,7 +73,7 @@
 endfunction(hex_to_dec)
 
 # Version information
-file(STRINGS "common/version.h" _brotli_version_line REGEX "^#define BROTLI_VERSION (0x[0-9a-fA-F]+)$")
+file(STRINGS "c/common/version.h" _brotli_version_line REGEX "^#define BROTLI_VERSION (0x[0-9a-fA-F]+)$")
 string(REGEX REPLACE "^#define BROTLI_VERSION 0x([0-9a-fA-F]+)$" "\\1" _brotli_version_hex "${_brotli_version_line}")
 hex_to_dec("${_brotli_version_hex}" _brotli_version)
 math(EXPR BROTLI_VERSION_MAJOR "${_brotli_version} >> 24")
@@ -112,7 +112,7 @@
 endif()
 unset(LOG2_RES)
 
-set(BROTLI_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include")
+set(BROTLI_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/c/include")
 set(BROTLI_LIBRARIES_CORE brotlienc brotlidec brotlicommon)
 set(BROTLI_LIBRARIES ${BROTLI_LIBRARIES_CORE} ${LIBM_LIBRARY})
 mark_as_advanced(BROTLI_INCLUDE_DIRS BROTLI_LIBRARIES)
@@ -126,30 +126,30 @@
 endif()
 
 add_library(brotlicommon
-  common/dictionary.c)
+  c/common/dictionary.c)
 add_library(brotlidec
-  dec/bit_reader.c
-  dec/decode.c
-  dec/huffman.c
-  dec/state.c)
+  c/dec/bit_reader.c
+  c/dec/decode.c
+  c/dec/huffman.c
+  c/dec/state.c)
 add_library(brotlienc
-  enc/backward_references.c
-  enc/backward_references_hq.c
-  enc/bit_cost.c
-  enc/block_splitter.c
-  enc/brotli_bit_stream.c
-  enc/cluster.c
-  enc/compress_fragment.c
-  enc/compress_fragment_two_pass.c
-  enc/dictionary_hash.c
-  enc/encode.c
-  enc/entropy_encode.c
-  enc/histogram.c
-  enc/literal_cost.c
-  enc/memory.c
-  enc/metablock.c
-  enc/static_dict.c
-  enc/utf8_util.c)
+  c/enc/backward_references.c
+  c/enc/backward_references_hq.c
+  c/enc/bit_cost.c
+  c/enc/block_splitter.c
+  c/enc/brotli_bit_stream.c
+  c/enc/cluster.c
+  c/enc/compress_fragment.c
+  c/enc/compress_fragment_two_pass.c
+  c/enc/dictionary_hash.c
+  c/enc/encode.c
+  c/enc/entropy_encode.c
+  c/enc/histogram.c
+  c/enc/literal_cost.c
+  c/enc/memory.c
+  c/enc/metablock.c
+  c/enc/static_dict.c
+  c/enc/utf8_util.c)
 
 # Older CMake versions does not understand INCLUDE_DIRECTORIES property.
 include_directories(${BROTLI_INCLUDE_DIRS})
@@ -182,7 +182,7 @@
 endif()
 
 # Build the bro executable
-add_executable(bro tools/bro.c)
+add_executable(bro c/tools/bro.c)
 target_link_libraries(bro ${BROTLI_LIBRARIES})
 
 # Installation
@@ -229,9 +229,9 @@
     tests/testdata/asyoulik.txt
     tests/testdata/lcet10.txt
     tests/testdata/plrabn12.txt
-    enc/encode.c
-    common/dictionary.h
-    dec/decode.c)
+    c/enc/encode.c
+    c/common/dictionary.h
+    c/dec/decode.c)
 
   foreach(INPUT ${ROUNDTRIP_INPUTS})
     get_filename_component(OUTPUT_NAME "${INPUT}" NAME)
diff --git a/MANIFEST.in b/MANIFEST.in
index edad2ed..6d4a12c 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,11 +1,11 @@
 include CONTRIBUTING.md
-include common/*.c
-include common/*.h
-include dec/*.c
-include dec/*.h
-include enc/*.c
-include enc/*.h
-include include/brotli/*.h
+include c/common/*.c
+include c/common/*.h
+include c/dec/*.c
+include c/dec/*.h
+include c/enc/*.c
+include c/enc/*.h
+include c/include/brotli/*.h
 include LICENSE
 include MANIFEST.in
 include python/bro.py
@@ -13,4 +13,4 @@
 include python/README.md
 include README.md
 include setup.py
-include tools/bro.c
+include c/tools/bro.c
diff --git a/Makefile b/Makefile
index 9dc5ecc..09e6818 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,14 @@
 OS := $(shell uname)
-LIBSOURCES = $(wildcard common/*.c) $(wildcard dec/*.c) $(wildcard enc/*.c)
-SOURCES = $(LIBSOURCES) tools/bro.c
+LIBSOURCES = $(wildcard c/common/*.c) $(wildcard c/dec/*.c) $(wildcard c/enc/*.c)
+SOURCES = $(LIBSOURCES) c/tools/bro.c
 BINDIR = bin
 OBJDIR = $(BINDIR)/obj
 LIBOBJECTS = $(addprefix $(OBJDIR)/, $(LIBSOURCES:.c=.o))
 OBJECTS = $(addprefix $(OBJDIR)/, $(SOURCES:.c=.o))
 LIB_A = libbrotli.a
 EXECUTABLE = bro
-DIRS = $(OBJDIR)/common $(OBJDIR)/dec $(OBJDIR)/enc \
-       $(OBJDIR)/tools $(BINDIR)/tmp
+DIRS = $(OBJDIR)/c/common $(OBJDIR)/c/dec $(OBJDIR)/c/enc \
+       $(OBJDIR)/c/tools $(BINDIR)/tmp
 CFLAGS += -O2
 ifeq ($(os), Darwin)
   CPPFLAGS += -DOS_MACOSX
@@ -38,5 +38,5 @@
 
 .SECONDEXPANSION:
 $(OBJECTS): $$(patsubst %.o,%.c,$$(patsubst $$(OBJDIR)/%,%,$$@)) | $(DIRS)
-	$(CC) $(CFLAGS) $(CPPFLAGS) -Iinclude \
+	$(CC) $(CFLAGS) $(CPPFLAGS) -Ic/include \
         -c $(patsubst %.o,%.c,$(patsubst $(OBJDIR)/%,%,$@)) -o $@
diff --git a/common/constants.h b/c/common/constants.h
similarity index 100%
rename from common/constants.h
rename to c/common/constants.h
diff --git a/common/dictionary.c b/c/common/dictionary.c
similarity index 100%
rename from common/dictionary.c
rename to c/common/dictionary.c
diff --git a/common/dictionary.h b/c/common/dictionary.h
similarity index 100%
rename from common/dictionary.h
rename to c/common/dictionary.h
diff --git a/common/version.h b/c/common/version.h
similarity index 100%
rename from common/version.h
rename to c/common/version.h
diff --git a/dec/bit_reader.c b/c/dec/bit_reader.c
similarity index 100%
rename from dec/bit_reader.c
rename to c/dec/bit_reader.c
diff --git a/dec/bit_reader.h b/c/dec/bit_reader.h
similarity index 100%
rename from dec/bit_reader.h
rename to c/dec/bit_reader.h
diff --git a/dec/context.h b/c/dec/context.h
similarity index 100%
rename from dec/context.h
rename to c/dec/context.h
diff --git a/dec/decode.c b/c/dec/decode.c
similarity index 100%
rename from dec/decode.c
rename to c/dec/decode.c
diff --git a/dec/huffman.c b/c/dec/huffman.c
similarity index 100%
rename from dec/huffman.c
rename to c/dec/huffman.c
diff --git a/dec/huffman.h b/c/dec/huffman.h
similarity index 100%
rename from dec/huffman.h
rename to c/dec/huffman.h
diff --git a/dec/port.h b/c/dec/port.h
similarity index 100%
rename from dec/port.h
rename to c/dec/port.h
diff --git a/dec/prefix.h b/c/dec/prefix.h
similarity index 100%
rename from dec/prefix.h
rename to c/dec/prefix.h
diff --git a/dec/state.c b/c/dec/state.c
similarity index 100%
rename from dec/state.c
rename to c/dec/state.c
diff --git a/dec/state.h b/c/dec/state.h
similarity index 100%
rename from dec/state.h
rename to c/dec/state.h
diff --git a/dec/transform.h b/c/dec/transform.h
similarity index 100%
rename from dec/transform.h
rename to c/dec/transform.h
diff --git a/enc/backward_references.c b/c/enc/backward_references.c
similarity index 100%
rename from enc/backward_references.c
rename to c/enc/backward_references.c
diff --git a/enc/backward_references.h b/c/enc/backward_references.h
similarity index 100%
rename from enc/backward_references.h
rename to c/enc/backward_references.h
diff --git a/enc/backward_references_hq.c b/c/enc/backward_references_hq.c
similarity index 100%
rename from enc/backward_references_hq.c
rename to c/enc/backward_references_hq.c
diff --git a/enc/backward_references_hq.h b/c/enc/backward_references_hq.h
similarity index 100%
rename from enc/backward_references_hq.h
rename to c/enc/backward_references_hq.h
diff --git a/enc/backward_references_inc.h b/c/enc/backward_references_inc.h
similarity index 100%
rename from enc/backward_references_inc.h
rename to c/enc/backward_references_inc.h
diff --git a/enc/bit_cost.c b/c/enc/bit_cost.c
similarity index 100%
rename from enc/bit_cost.c
rename to c/enc/bit_cost.c
diff --git a/enc/bit_cost.h b/c/enc/bit_cost.h
similarity index 100%
rename from enc/bit_cost.h
rename to c/enc/bit_cost.h
diff --git a/enc/bit_cost_inc.h b/c/enc/bit_cost_inc.h
similarity index 100%
rename from enc/bit_cost_inc.h
rename to c/enc/bit_cost_inc.h
diff --git a/enc/block_encoder_inc.h b/c/enc/block_encoder_inc.h
similarity index 100%
rename from enc/block_encoder_inc.h
rename to c/enc/block_encoder_inc.h
diff --git a/enc/block_splitter.c b/c/enc/block_splitter.c
similarity index 100%
rename from enc/block_splitter.c
rename to c/enc/block_splitter.c
diff --git a/enc/block_splitter.h b/c/enc/block_splitter.h
similarity index 100%
rename from enc/block_splitter.h
rename to c/enc/block_splitter.h
diff --git a/enc/block_splitter_inc.h b/c/enc/block_splitter_inc.h
similarity index 100%
rename from enc/block_splitter_inc.h
rename to c/enc/block_splitter_inc.h
diff --git a/enc/brotli_bit_stream.c b/c/enc/brotli_bit_stream.c
similarity index 100%
rename from enc/brotli_bit_stream.c
rename to c/enc/brotli_bit_stream.c
diff --git a/enc/brotli_bit_stream.h b/c/enc/brotli_bit_stream.h
similarity index 100%
rename from enc/brotli_bit_stream.h
rename to c/enc/brotli_bit_stream.h
diff --git a/enc/cluster.c b/c/enc/cluster.c
similarity index 100%
rename from enc/cluster.c
rename to c/enc/cluster.c
diff --git a/enc/cluster.h b/c/enc/cluster.h
similarity index 100%
rename from enc/cluster.h
rename to c/enc/cluster.h
diff --git a/enc/cluster_inc.h b/c/enc/cluster_inc.h
similarity index 100%
rename from enc/cluster_inc.h
rename to c/enc/cluster_inc.h
diff --git a/enc/command.h b/c/enc/command.h
similarity index 100%
rename from enc/command.h
rename to c/enc/command.h
diff --git a/enc/compress_fragment.c b/c/enc/compress_fragment.c
similarity index 100%
rename from enc/compress_fragment.c
rename to c/enc/compress_fragment.c
diff --git a/enc/compress_fragment.h b/c/enc/compress_fragment.h
similarity index 100%
rename from enc/compress_fragment.h
rename to c/enc/compress_fragment.h
diff --git a/enc/compress_fragment_two_pass.c b/c/enc/compress_fragment_two_pass.c
similarity index 100%
rename from enc/compress_fragment_two_pass.c
rename to c/enc/compress_fragment_two_pass.c
diff --git a/enc/compress_fragment_two_pass.h b/c/enc/compress_fragment_two_pass.h
similarity index 100%
rename from enc/compress_fragment_two_pass.h
rename to c/enc/compress_fragment_two_pass.h
diff --git a/enc/context.h b/c/enc/context.h
similarity index 100%
rename from enc/context.h
rename to c/enc/context.h
diff --git a/enc/dictionary_hash.c b/c/enc/dictionary_hash.c
similarity index 100%
rename from enc/dictionary_hash.c
rename to c/enc/dictionary_hash.c
diff --git a/enc/dictionary_hash.h b/c/enc/dictionary_hash.h
similarity index 100%
rename from enc/dictionary_hash.h
rename to c/enc/dictionary_hash.h
diff --git a/enc/encode.c b/c/enc/encode.c
similarity index 100%
rename from enc/encode.c
rename to c/enc/encode.c
diff --git a/enc/entropy_encode.c b/c/enc/entropy_encode.c
similarity index 100%
rename from enc/entropy_encode.c
rename to c/enc/entropy_encode.c
diff --git a/enc/entropy_encode.h b/c/enc/entropy_encode.h
similarity index 100%
rename from enc/entropy_encode.h
rename to c/enc/entropy_encode.h
diff --git a/enc/entropy_encode_static.h b/c/enc/entropy_encode_static.h
similarity index 100%
rename from enc/entropy_encode_static.h
rename to c/enc/entropy_encode_static.h
diff --git a/enc/fast_log.h b/c/enc/fast_log.h
similarity index 100%
rename from enc/fast_log.h
rename to c/enc/fast_log.h
diff --git a/enc/find_match_length.h b/c/enc/find_match_length.h
similarity index 100%
rename from enc/find_match_length.h
rename to c/enc/find_match_length.h
diff --git a/enc/hash.h b/c/enc/hash.h
similarity index 100%
rename from enc/hash.h
rename to c/enc/hash.h
diff --git a/enc/hash_forgetful_chain_inc.h b/c/enc/hash_forgetful_chain_inc.h
similarity index 100%
rename from enc/hash_forgetful_chain_inc.h
rename to c/enc/hash_forgetful_chain_inc.h
diff --git a/enc/hash_longest_match64_inc.h b/c/enc/hash_longest_match64_inc.h
similarity index 100%
rename from enc/hash_longest_match64_inc.h
rename to c/enc/hash_longest_match64_inc.h
diff --git a/enc/hash_longest_match_inc.h b/c/enc/hash_longest_match_inc.h
similarity index 100%
rename from enc/hash_longest_match_inc.h
rename to c/enc/hash_longest_match_inc.h
diff --git a/enc/hash_longest_match_quickly_inc.h b/c/enc/hash_longest_match_quickly_inc.h
similarity index 100%
rename from enc/hash_longest_match_quickly_inc.h
rename to c/enc/hash_longest_match_quickly_inc.h
diff --git a/enc/hash_to_binary_tree_inc.h b/c/enc/hash_to_binary_tree_inc.h
similarity index 100%
rename from enc/hash_to_binary_tree_inc.h
rename to c/enc/hash_to_binary_tree_inc.h
diff --git a/enc/histogram.c b/c/enc/histogram.c
similarity index 100%
rename from enc/histogram.c
rename to c/enc/histogram.c
diff --git a/enc/histogram.h b/c/enc/histogram.h
similarity index 100%
rename from enc/histogram.h
rename to c/enc/histogram.h
diff --git a/enc/histogram_inc.h b/c/enc/histogram_inc.h
similarity index 100%
rename from enc/histogram_inc.h
rename to c/enc/histogram_inc.h
diff --git a/enc/literal_cost.c b/c/enc/literal_cost.c
similarity index 100%
rename from enc/literal_cost.c
rename to c/enc/literal_cost.c
diff --git a/enc/literal_cost.h b/c/enc/literal_cost.h
similarity index 100%
rename from enc/literal_cost.h
rename to c/enc/literal_cost.h
diff --git a/enc/memory.c b/c/enc/memory.c
similarity index 100%
rename from enc/memory.c
rename to c/enc/memory.c
diff --git a/enc/memory.h b/c/enc/memory.h
similarity index 100%
rename from enc/memory.h
rename to c/enc/memory.h
diff --git a/enc/metablock.c b/c/enc/metablock.c
similarity index 100%
rename from enc/metablock.c
rename to c/enc/metablock.c
diff --git a/enc/metablock.h b/c/enc/metablock.h
similarity index 100%
rename from enc/metablock.h
rename to c/enc/metablock.h
diff --git a/enc/metablock_inc.h b/c/enc/metablock_inc.h
similarity index 100%
rename from enc/metablock_inc.h
rename to c/enc/metablock_inc.h
diff --git a/enc/port.h b/c/enc/port.h
similarity index 100%
rename from enc/port.h
rename to c/enc/port.h
diff --git a/enc/prefix.h b/c/enc/prefix.h
similarity index 100%
rename from enc/prefix.h
rename to c/enc/prefix.h
diff --git a/enc/quality.h b/c/enc/quality.h
similarity index 100%
rename from enc/quality.h
rename to c/enc/quality.h
diff --git a/enc/ringbuffer.h b/c/enc/ringbuffer.h
similarity index 100%
rename from enc/ringbuffer.h
rename to c/enc/ringbuffer.h
diff --git a/enc/static_dict.c b/c/enc/static_dict.c
similarity index 100%
rename from enc/static_dict.c
rename to c/enc/static_dict.c
diff --git a/enc/static_dict.h b/c/enc/static_dict.h
similarity index 100%
rename from enc/static_dict.h
rename to c/enc/static_dict.h
diff --git a/enc/static_dict_lut.h b/c/enc/static_dict_lut.h
similarity index 100%
rename from enc/static_dict_lut.h
rename to c/enc/static_dict_lut.h
diff --git a/enc/utf8_util.c b/c/enc/utf8_util.c
similarity index 100%
rename from enc/utf8_util.c
rename to c/enc/utf8_util.c
diff --git a/enc/utf8_util.h b/c/enc/utf8_util.h
similarity index 100%
rename from enc/utf8_util.h
rename to c/enc/utf8_util.h
diff --git a/enc/write_bits.h b/c/enc/write_bits.h
similarity index 100%
rename from enc/write_bits.h
rename to c/enc/write_bits.h
diff --git a/fuzz/decode_fuzzer.cc b/c/fuzz/decode_fuzzer.cc
similarity index 100%
rename from fuzz/decode_fuzzer.cc
rename to c/fuzz/decode_fuzzer.cc
diff --git a/fuzz/run_decode_fuzzer.cc b/c/fuzz/run_decode_fuzzer.cc
similarity index 100%
rename from fuzz/run_decode_fuzzer.cc
rename to c/fuzz/run_decode_fuzzer.cc
diff --git a/fuzz/test_fuzzer.sh b/c/fuzz/test_fuzzer.sh
similarity index 100%
rename from fuzz/test_fuzzer.sh
rename to c/fuzz/test_fuzzer.sh
diff --git a/include/brotli/decode.h b/c/include/brotli/decode.h
similarity index 100%
rename from include/brotli/decode.h
rename to c/include/brotli/decode.h
diff --git a/include/brotli/encode.h b/c/include/brotli/encode.h
similarity index 100%
rename from include/brotli/encode.h
rename to c/include/brotli/encode.h
diff --git a/include/brotli/port.h b/c/include/brotli/port.h
similarity index 100%
rename from include/brotli/port.h
rename to c/include/brotli/port.h
diff --git a/include/brotli/types.h b/c/include/brotli/types.h
similarity index 100%
rename from include/brotli/types.h
rename to c/include/brotli/types.h
diff --git a/tools/bro.c b/c/tools/bro.c
similarity index 100%
rename from tools/bro.c
rename to c/tools/bro.c
diff --git a/configure-cmake b/configure-cmake
index 9f32456..6dfb92c 100755
--- a/configure-cmake
+++ b/configure-cmake
@@ -32,8 +32,8 @@
 LIBDIR=
 CMAKE_ARGS=
 
-if [ -e "${TOP_SRCDIR}/.configure-custom.sh" ]; then
-    . "${TOP_SRCDIR}/.configure-custom.sh"
+if [ -e "${TOP_SRCDIR}/scripts/.configure-custom.sh" ]; then
+    . "${TOP_SRCDIR}/scripts/.configure-custom.sh"
 fi
 
 quote() {
diff --git a/premake5.lua b/premake5.lua
index 68217d7..63fa5de 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -4,7 +4,7 @@
 targetdir "bin"
 location "buildfiles"
 flags "RelativeLinks"
-includedirs { "include" }
+includedirs { "c/include" }
 
 filter "configurations:Release"
   optimize "Speed"
@@ -29,43 +29,43 @@
 project "brotlicommon"
   kind "SharedLib"
   language "C"
-  files { "common/**.h", "common/**.c" }
+  files { "c/common/**.h", "c/common/**.c" }
 
 project "brotlicommon_static"
   kind "StaticLib"
   targetname "brotlicommon"
   language "C"
-  files { "common/**.h", "common/**.c" }
+  files { "c/common/**.h", "c/common/**.c" }
 
 project "brotlidec"
   kind "SharedLib"
   language "C"
-  files { "dec/**.h", "dec/**.c" }
+  files { "c/dec/**.h", "c/dec/**.c" }
   links "brotlicommon"
 
 project "brotlidec_static"
   kind "StaticLib"
   targetname "brotlidec"
   language "C"
-  files { "dec/**.h", "dec/**.c" }
+  files { "c/dec/**.h", "c/dec/**.c" }
   links "brotlicommon_static"
 
 project "brotlienc"
   kind "SharedLib"
   language "C"
-  files { "enc/**.h", "enc/**.c" }
+  files { "c/enc/**.h", "c/enc/**.c" }
   links "brotlicommon"
 
 project "brotlienc_static"
   kind "StaticLib"
   targetname "brotlienc"
   language "C"
-  files { "enc/**.h", "enc/**.c" }
+  files { "c/enc/**.h", "c/enc/**.c" }
   links "brotlicommon_static"
 
 project "bro"
   kind "ConsoleApp"
   language "C"
   linkoptions "-static"
-  files { "tools/bro.c" }
+  files { "c/tools/bro.c" }
   links { "brotlicommon_static", "brotlidec_static", "brotlienc_static" }
diff --git a/.bintray.json b/scripts/.bintray.json
similarity index 100%
rename from .bintray.json
rename to scripts/.bintray.json
diff --git a/.configure-custom.sh b/scripts/.configure-custom.sh
similarity index 100%
rename from .configure-custom.sh
rename to scripts/.configure-custom.sh
diff --git a/.travis.sh b/scripts/.travis.sh
similarity index 96%
rename from .travis.sh
rename to scripts/.travis.sh
index d84d105..458dcdc 100755
--- a/.travis.sh
+++ b/scripts/.travis.sh
@@ -28,7 +28,7 @@
 
 		case "${BUILD_SYSTEM}" in
 		    "python")
-			source terryfy/travis_tools.sh
+			source scripts/terryfy/travis_tools.sh
 			get_python_environment $INSTALL_TYPE $PYTHON_VERSION venv
 			pip install --upgrade wheel
 			;;
@@ -91,7 +91,7 @@
 	case "${BUILD_SYSTEM}" in
 	    "bazel")
 		export RELEASE_DATE=`date +%Y-%m-%d`
-		perl -p -i -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' .bintray.json
+		perl -p -i -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' scripts/.bintray.json
 		zip -j9 brotli.zip bazel-bin/libbrotli*.a bazel-bin/libbrotli*.so bazel-bin/bro
 		;;
 	esac
diff --git a/appveyor.yml b/scripts/appveyor.yml
similarity index 92%
rename from appveyor.yml
rename to scripts/appveyor.yml
index 01f2789..617f324 100644
--- a/appveyor.yml
+++ b/scripts/appveyor.yml
@@ -4,7 +4,7 @@
     # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the

     # /E:ON and /V:ON options are not enabled in the batch script intepreter

     # See: http://stackoverflow.com/a/13751649/163740

-    WITH_COMPILER: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_compiler.cmd"

+    WITH_COMPILER: "cmd /E:ON /V:ON /C .\\scripts\\run_with_compiler.cmd"

 

   matrix:

     - BUILD_SYSTEM: CMake

@@ -49,14 +49,11 @@
       PYTHON_VERSION: "3.5.0"

       PYTHON_ARCH: "64"

 

-# init:

-#   - "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%"

-

 install:

   - ps: |

       if ($env:BUILD_SYSTEM -eq "Python") {

         # install Python and pip when not already installed

-        if (-not(Test-Path($env:PYTHON))) { & appveyor\install.ps1 }

+        if (-not(Test-Path($env:PYTHON))) { & scripts\install_py.ps1 }

 

         # prepend newly installed Python to the PATH

         $env:Path = $env:PYTHON + ';' + $env:PYTHON + '\\Scripts;' + $env:PATH

diff --git a/appveyor/install.ps1 b/scripts/install_py.ps1
similarity index 100%
rename from appveyor/install.ps1
rename to scripts/install_py.ps1
diff --git a/appveyor/run_with_compiler.cmd b/scripts/run_with_compiler.cmd
similarity index 100%
rename from appveyor/run_with_compiler.cmd
rename to scripts/run_with_compiler.cmd
diff --git a/terryfy b/scripts/terryfy
similarity index 100%
rename from terryfy
rename to scripts/terryfy
diff --git a/setup.py b/setup.py
index ce39a47..6dd513f 100644
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@
 
 def get_version():
     """ Return BROTLI_VERSION string as defined in 'common/version.h' file. """
-    version_file_path = os.path.join(CURR_DIR, 'common', 'version.h')
+    version_file_path = os.path.join(CURR_DIR, 'c', 'common', 'version.h')
     version = 0
     with open(version_file_path, 'r') as f:
         for line in f:
@@ -164,82 +164,83 @@
         '_brotli',
         sources=[
             'python/_brotli.cc',
-            'common/dictionary.c',
-            'dec/bit_reader.c',
-            'dec/decode.c',
-            'dec/huffman.c',
-            'dec/state.c',
-            'enc/backward_references.c',
-            'enc/backward_references_hq.c',
-            'enc/bit_cost.c',
-            'enc/block_splitter.c',
-            'enc/brotli_bit_stream.c',
-            'enc/cluster.c',
-            'enc/compress_fragment.c',
-            'enc/compress_fragment_two_pass.c',
-            'enc/dictionary_hash.c',
-            'enc/encode.c',
-            'enc/entropy_encode.c',
-            'enc/histogram.c',
-            'enc/literal_cost.c',
-            'enc/memory.c',
-            'enc/metablock.c',
-            'enc/static_dict.c',
-            'enc/utf8_util.c',
+            'c/common/dictionary.c',
+            'c/dec/bit_reader.c',
+            'c/dec/decode.c',
+            'c/dec/huffman.c',
+            'c/dec/state.c',
+            'c/enc/backward_references.c',
+            'c/enc/backward_references_hq.c',
+            'c/enc/bit_cost.c',
+            'c/enc/block_splitter.c',
+            'c/enc/brotli_bit_stream.c',
+            'c/enc/cluster.c',
+            'c/enc/compress_fragment.c',
+            'c/enc/compress_fragment_two_pass.c',
+            'c/enc/dictionary_hash.c',
+            'c/enc/encode.c',
+            'c/enc/entropy_encode.c',
+            'c/enc/histogram.c',
+            'c/enc/literal_cost.c',
+            'c/enc/memory.c',
+            'c/enc/metablock.c',
+            'c/enc/static_dict.c',
+            'c/enc/utf8_util.c',
         ],
         depends=[
-            'common/constants.h',
-            'common/dictionary.h',
-            'common/port.h',
-            'common/version.h',
-            'dec/bit_reader.h',
-            'dec/context.h',
-            'dec/huffman.h',
-            'dec/port.h',
-            'dec/prefix.h',
-            'dec/state.h',
-            'dec/streams.h',
-            'dec/transform.h',
-            'enc/backward_references.h',
-            'enc/backward_references_hq.h',
-            'enc/backward_references_inc.h',
-            'enc/bit_cost.h',
-            'enc/bit_cost_inc.h',
-            'enc/block_splitter.h',
-            'enc/block_splitter_inc.h',
-            'enc/brotli_bit_stream.h',
-            'enc/cluster.h',
-            'enc/cluster_inc.h',
-            'enc/command.h',
-            'enc/compress_fragment.h',
-            'enc/compress_fragment_two_pass.h'
-            'enc/context.h',
-            'enc/dictionary_hash.h',
-            'enc/entropy_encode.h',
-            'enc/entropy_encode_static.h',
-            'enc/fast_log.h',
-            'enc/find_match_length.h',
-            'enc/hash.h',
-            'enc/hash_to_binary_tree_inc.h',
-            'enc/hash_longest_match64_inc.h',
-            'enc/hash_longest_match_inc.h',
-            'enc/hash_longest_match_quickly_inc.h',
-            'enc/histogram.h',
-            'enc/histogram_inc.h',
-            'enc/literal_cost.h',
-            'enc/memory.h',
-            'enc/metablock.h',
-            'enc/metablock_inc.h',
-            'enc/port.h',
-            'enc/prefix.h',
-            'enc/ringbuffer.h',
-            'enc/static_dict.h',
-            'enc/static_dict_lut.h',
-            'enc/utf8_util.h',
-            'enc/write_bits.h',
+            'c/common/constants.h',
+            'c/common/dictionary.h',
+            'c/common/version.h',
+            'c/dec/bit_reader.h',
+            'c/dec/context.h',
+            'c/dec/huffman.h',
+            'c/dec/port.h',
+            'c/dec/prefix.h',
+            'c/dec/state.h',
+            'c/dec/transform.h',
+            'c/enc/backward_references.h',
+            'c/enc/backward_references_hq.h',
+            'c/enc/backward_references_inc.h',
+            'c/enc/bit_cost.h',
+            'c/enc/bit_cost_inc.h',
+            'c/enc/block_encoder_inc.h',
+            'c/enc/block_splitter.h',
+            'c/enc/block_splitter_inc.h',
+            'c/enc/brotli_bit_stream.h',
+            'c/enc/cluster.h',
+            'c/enc/cluster_inc.h',
+            'c/enc/command.h',
+            'c/enc/compress_fragment.h',
+            'c/enc/compress_fragment_two_pass.h'
+            'c/enc/context.h',
+            'c/enc/dictionary_hash.h',
+            'c/enc/entropy_encode.h',
+            'c/enc/entropy_encode_static.h',
+            'c/enc/fast_log.h',
+            'c/enc/find_match_length.h',
+            'c/enc/hash.h',
+            'c/enc/hash_forgetful_chain_inc.h',
+            'c/enc/hash_longest_match64_inc.h',
+            'c/enc/hash_longest_match_inc.h',
+            'c/enc/hash_longest_match_quickly_inc.h',
+            'c/enc/hash_to_binary_tree_inc.h',
+            'c/enc/histogram.h',
+            'c/enc/histogram_inc.h',
+            'c/enc/literal_cost.h',
+            'c/enc/memory.h',
+            'c/enc/metablock.h',
+            'c/enc/metablock_inc.h',
+            'c/enc/port.h',
+            'c/enc/prefix.h',
+            'c/enc/quality.h',
+            'c/enc/ringbuffer.h',
+            'c/enc/static_dict.h',
+            'c/enc/static_dict_lut.h',
+            'c/enc/utf8_util.h',
+            'c/enc/write_bits.h',
         ],
         include_dirs=[
-            'include',
+            'c/include',
         ],
         language='c++'),
 ]
diff --git a/tests/Makefile b/tests/Makefile
index 7962cbd..5d847e5 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -13,5 +13,5 @@
 
 clean :
 	rm -f testdata/*.{bro,unbro,uncompressed}
-	rm -f $(BROTLI)/{enc,dec,tools}/*.{un,}bro
-	$(MAKE) -C $(BROTLI)/tools clean
+	rm -f $(BROTLI)/c/{enc,dec,tools}/*.{un,}bro
+	$(MAKE) -C $(BROTLI)/c/tools clean
diff --git a/tests/roundtrip_test.sh b/tests/roundtrip_test.sh
index 6bdfa59..6a00a26 100755
--- a/tests/roundtrip_test.sh
+++ b/tests/roundtrip_test.sh
@@ -11,9 +11,9 @@
 tests/testdata/asyoulik.txt
 tests/testdata/lcet10.txt
 tests/testdata/plrabn12.txt
-enc/encode.c
-common/dictionary.h
-dec/decode.c
+c/enc/encode.c
+c/common/dictionary.h
+c/dec/decode.c
 $BRO
 """