diff --git a/Makefile.am b/Makefile.am
index 791b19802f6cd8f10f7ccecea6051156781773be..cacb74f81d88ffb8653d866540219d4b9396df59 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,8 @@ AUTOMAKE_OPTIONS = subdir-objects
 
 lib_LTLIBRARIES = libopus.la
 
+SUBDIRS = . libcelt
+
 INCLUDES = -I$(top_srcdir)/libcelt -I$(top_srcdir)/silk -I$(top_srcdir)/silk/float -I$(top_srcdir)/silk/fixed
 
 include celt_sources.mk
diff --git a/configure.ac b/configure.ac
index 8da18e6c06b4bbc6e0e2959dd6d61610e3d2cdd0..9b10e8a3a90922a8617e0306be7478bbd1c8fa92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -200,7 +200,7 @@ fi
 
 AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
 
-AC_OUTPUT([Makefile])
+AC_OUTPUT([Makefile libcelt/Makefile])
 
 AC_MSG_RESULT([
 ------------------------------------------------------------------------
diff --git a/libcelt/Makefile.am b/libcelt/Makefile.am
index 2f1ac73bef840b8d5978e1e7e13326d1c63adadc..0d1df1e274eaa28d2bf84a28902abb0d1cac4cfc 100644
--- a/libcelt/Makefile.am
+++ b/libcelt/Makefile.am
@@ -1,39 +1,17 @@
-# Disable automatic dependency tracking if using other tools than gcc and gmake
-#AUTOMAKE_OPTIONS = no-dependencies
-
-
-pkginclude_HEADERS = celt.h celt_types.h celt_header.h
-EXTRA_DIST= match-test.sh libcelt.vcxproj  libcelt.vcxproj.filters
-
-#INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@
-
-TESTS = match-test.sh
-
-noinst_SCRIPTS = match-test.sh
-
-lib_LTLIBRARIES = libcelt@LIBCELT_SUFFIX@.la
-
-# Sources for compilation in the library
-libcelt@LIBCELT_SUFFIX@_la_SOURCES = bands.c celt.c cwrs.c ecintrin.h entcode.c \
-	entdec.c entenc.c header.c kiss_fft.c laplace.c mathops.c mdct.c \
-	modes.c pitch.c plc.c quant_bands.c rate.c vq.c
-
-libcelt@LIBCELT_SUFFIX@_la_LDFLAGS = \
-	-version-info @CELT_LT_CURRENT@:@CELT_LT_REVISION@:@CELT_LT_AGE@ \
-	-no-undefined
-
-noinst_HEADERS = _kiss_fft_guts.h arch.h bands.h fixed_c5x.h fixed_c6x.h \
-	cwrs.h ecintrin.h entcode.h entdec.h entenc.h fixed_generic.h float_cast.h \
-	kiss_fft.h laplace.h mdct.h mfrngcod.h \
-	mathops.h modes.h os_support.h pitch.h \
-	quant_bands.h rate.h stack_alloc.h \
-	static_modes_fixed.h static_modes_float.h vq.h plc.h
-
-noinst_PROGRAMS = testcelt dump_modes
-testcelt_SOURCES = testcelt.c
-testcelt_LDADD = libcelt@LIBCELT_SUFFIX@.la
-INCLUDES =
-#libcelt@LIBCELT_SUFFIX@_la_LIBADD =
-
-dump_modes_SOURCES = dump_modes.c
-dump_modes_LDADD = libcelt@LIBCELT_SUFFIX@.la
+INCLUDES = -I$(top_srcdir)/libcelt
+METASOURCES = AUTO
+
+TESTS = type-test ectest cwrs32-test dft-test laplace-test mdct-test mathops-test rotation-test tandem-test
+
+noinst_PROGRAMS = type-test ectest cwrs32-test dft-test laplace-test mdct-test mathops-test rotation-test tandem-test
+
+type_test_SOURCES = tests/type-test.c
+ectest_SOURCES = tests/ectest.c
+cwrs32_test_SOURCES = tests/cwrs32-test.c
+dft_test_SOURCES = tests/dft-test.c
+laplace_test_SOURCES = tests/laplace-test.c
+mdct_test_SOURCES = tests/mdct-test.c
+rotation_test_SOURCES = tests/rotation-test.c
+mathops_test_SOURCES = tests/mathops-test.c
+tandem_test_SOURCES = tests/tandem-test.c
+tandem_test_LDADD = $(top_builddir)/libopus.la
diff --git a/libcelt/tests/Makefile.am b/libcelt/tests/Makefile.am
deleted file mode 100644
index 5a7b508c78fb93a2ceba470906a5914890446bbc..0000000000000000000000000000000000000000
--- a/libcelt/tests/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-INCLUDES = -I$(top_srcdir)/libcelt
-METASOURCES = AUTO
-
-TESTS = type-test ectest cwrs32-test dft-test laplace-test mdct-test mathops-test tandem-test
-
-noinst_PROGRAMS = type-test ectest cwrs32-test dft-test laplace-test mdct-test mathops-test tandem-test
-
-type_test_SOURCES = type-test.c
-ectest_SOURCES = ectest.c
-cwrs32_test_SOURCES = cwrs32-test.c
-dft_test_SOURCES = dft-test.c
-laplace_test_SOURCES = laplace-test.c
-mdct_test_SOURCES = mdct-test.c
-#rotation_test_SOURCES = rotation-test.c
-mathops_test_SOURCES = mathops-test.c
-tandem_test_SOURCES = tandem-test.c
-tandem_test_LDADD = $(top_builddir)/libcelt/libcelt@LIBCELT_SUFFIX@.la
diff --git a/libcelt/tests/mathops-test.c b/libcelt/tests/mathops-test.c
index 9eb75d929ffe683a10be5081f34f508b0d246d8a..efe805370f04130049191a9b20a2b3c2aff1e11f 100644
--- a/libcelt/tests/mathops-test.c
+++ b/libcelt/tests/mathops-test.c
@@ -134,7 +134,7 @@ void testexp2log2(void)
    opus_val32 x;
    for (x=8;x<65536;x+=(x>>3))
    {
-      float error = fabs(x-0.25*celt_exp2(celt_log2(x)<<1))/16384;
+      float error = fabs(x-0.25*celt_exp2(celt_log2(x)))/16384;
       if (error>0.004)
       {
          fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_exp2(celt_log2(x))))>0.001 (x = %ld, error = %f)\n", (long)x,error);
diff --git a/libcelt/tests/rotation-test.c b/libcelt/tests/rotation-test.c
index 1b9ee9fc9a2ec6d42ae091b959982ab2a22d75a5..0540568424fccca04e8651818b8c224c51f3cb5f 100644
--- a/libcelt/tests/rotation-test.c
+++ b/libcelt/tests/rotation-test.c
@@ -23,7 +23,6 @@ void test_rotation(int N, int K)
    double err = 0, ener = 0, snr, snr0;
    opus_val16 x0[MAX_SIZE];
    opus_val16 x1[MAX_SIZE];
-   int nb_rotations = (N+4*K)/(8*K);
    for (i=0;i<N;i++)
       x1[i] = x0[i] = rand()%32767-16384;
    exp_rotation(x1, N, 1, 1, K, SPREAD_NORMAL);