diff --git a/modules/calib3d/src/calibration.cpp b/modules/calib3d/src/calibration.cpp
index 62a1c3c006..21b7025320 100644
--- a/modules/calib3d/src/calibration.cpp
+++ b/modules/calib3d/src/calibration.cpp
@@ -412,7 +412,7 @@ CV_IMPL void cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1,
     cvRodrigues2( &r1, &R1, &dR1dr1 );
     cvRodrigues2( &r2, &R2, &dR2dr2 );
 
-    if( _rvec3 || dr3dr1 || dr3dr1 )
+    if( _rvec3 || dr3dr1 || dr3dr2 )
     {
         double _r3[3], _R3[9], _dR3dR1[9*9], _dR3dR2[9*9], _dr3dR3[9*3];
         double _W1[9*3], _W2[3*3];
diff --git a/modules/calib3d/src/posit.cpp b/modules/calib3d/src/posit.cpp
index 61f86a03eb..c8c1c2c2f1 100644
--- a/modules/calib3d/src/posit.cpp
+++ b/modules/calib3d/src/posit.cpp
@@ -119,12 +119,6 @@ static  CvStatus  icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
     float diff = (float)criteria.epsilon;
     float inv_focalLength = 1 / focalLength;
 
-    /* init variables */
-    int N = pObject->N;
-    float *objectVectors = pObject->obj_vecs;
-    float *invMatrix = pObject->inv_matr;
-    float *imgVectors = pObject->img_vecs;
-
     /* Check bad arguments */
     if( imagePoints == NULL )
         return CV_NULLPTR_ERR;
@@ -143,6 +137,12 @@ static  CvStatus  icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
     if( (criteria.type & CV_TERMCRIT_ITER) && criteria.max_iter <= 0 )
         return CV_BADFACTOR_ERR;
 
+    /* init variables */
+    int N = pObject->N;
+    float *objectVectors = pObject->obj_vecs;
+    float *invMatrix = pObject->inv_matr;
+    float *imgVectors = pObject->img_vecs;
+
     while( !converged )
     {
         if( count == 0 )
diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp
index f87364c7c5..01129d5515 100644
--- a/modules/core/src/persistence.cpp
+++ b/modules/core/src/persistence.cpp
@@ -584,11 +584,12 @@ cvGetHashedKey( CvFileStorage* fs, const char* str, int len, int create_missing
     CvStringHashNode* node = 0;
     unsigned hashval = 0;
     int i, tab_size;
-    CvStringHash* map = fs->str_hash;
 
     if( !fs )
         return 0;
 
+    CvStringHash* map = fs->str_hash;
+
     if( len < 0 )
     {
         for( i = 0; str[i] != '\0'; i++ )
diff --git a/modules/highgui/perf/perf_input.cpp b/modules/highgui/perf/perf_input.cpp
index a2ce1fe910..0c1e8e0a73 100644
--- a/modules/highgui/perf/perf_input.cpp
+++ b/modules/highgui/perf/perf_input.cpp
@@ -1,12 +1,13 @@
 #include "perf_precomp.hpp"
 
+#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+
 using namespace std;
 using namespace cv;
 using namespace perf;
 using std::tr1::make_tuple;
 using std::tr1::get;
 
-#ifndef ANDROID
 
 typedef perf::TestBaseWithParam<String> VideoCapture_Reading;
 
@@ -26,4 +27,4 @@ PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_
   SANITY_CHECK(dummy);
 }
 
-#endif //ANDROID
\ No newline at end of file
+#endif // BUILD_WITH_VIDEO_INPUT_SUPPORT
\ No newline at end of file
diff --git a/modules/highgui/perf/perf_output.cpp b/modules/highgui/perf/perf_output.cpp
index 00d7da2630..6428bb4f03 100644
--- a/modules/highgui/perf/perf_output.cpp
+++ b/modules/highgui/perf/perf_output.cpp
@@ -1,13 +1,13 @@
 #include "perf_precomp.hpp"
 
+#if BUILD_WITH_VIDEO_OUTPUT_SUPPORT
+
 using namespace std;
 using namespace cv;
 using namespace perf;
 using std::tr1::make_tuple;
 using std::tr1::get;
 
-#ifndef ANDROID
-
 typedef std::tr1::tuple<String, bool> VideoWriter_Writing_t;
 typedef perf::TestBaseWithParam<VideoWriter_Writing_t> VideoWriter_Writing;
 
@@ -31,4 +31,4 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame,
   SANITY_CHECK(dummy);
 }
 
-#endif //ANDROID
\ No newline at end of file
+#endif // BUILD_WITH_VIDEO_OUTPUT_SUPPORT
\ No newline at end of file
diff --git a/modules/highgui/perf/perf_precomp.hpp b/modules/highgui/perf/perf_precomp.hpp
index 2b57ad7eea..ec8a447fa1 100644
--- a/modules/highgui/perf/perf_precomp.hpp
+++ b/modules/highgui/perf/perf_precomp.hpp
@@ -16,4 +16,29 @@
 #error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
 #endif
 
+#if defined(HAVE_XINE)         || \
+    defined(HAVE_GSTREAMER)    || \
+    defined(HAVE_QUICKTIME)    || \
+    defined(HAVE_AVFOUNDATION) || \
+    /*defined(HAVE_OPENNI)     || too specialized */ \
+    defined(HAVE_FFMPEG)       || \
+    defined(WIN32) /* assume that we have ffmpeg */
+
+#  define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
+#else
+#  define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
+#endif
+
+#if /*defined(HAVE_XINE)       || */\
+    defined(HAVE_GSTREAMER)    || \
+    defined(HAVE_QUICKTIME)    || \
+    defined(HAVE_AVFOUNDATION) || \
+    defined(HAVE_FFMPEG)       || \
+    defined(WIN32) /* assume that we have ffmpeg */
+#  define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
+#else
+#  define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0
+#endif
+
+
 #endif
diff --git a/modules/highgui/test/test_ffmpeg.cpp b/modules/highgui/test/test_ffmpeg.cpp
index ed06a2cbdd..e84ef89bfb 100644
--- a/modules/highgui/test/test_ffmpeg.cpp
+++ b/modules/highgui/test/test_ffmpeg.cpp
@@ -186,7 +186,7 @@ class CreateVideoWriterInvoker :
 public:
     const static Size FrameSize;
     static std::string TmpDirectory;
-    
+
     CreateVideoWriterInvoker(std::vector<VideoWriter*>& _writers, std::vector<std::string>& _files) :
         ParallelLoopBody(), writers(&_writers), files(&_files)
     {
@@ -221,7 +221,7 @@ class WriteVideo_Invoker :
 {
 public:
     enum { FrameCount = 300 };
-    
+
     static const Scalar ObjectColor;
     static const Point Center;
 
@@ -229,11 +229,11 @@ public:
         ParallelLoopBody(), writers(&_writers)
     {
     }
-    
+
     static void GenerateFrame(Mat& frame, unsigned int i)
     {
         frame = Scalar::all(i % 255);
-        
+
         std::string text = to_string(i);
         putText(frame, text, Point(50, Center.y), FONT_HERSHEY_SIMPLEX, 5.0, ObjectColor, 5, CV_AA);
         circle(frame, Center, i + 2, ObjectColor, 2, CV_AA);
@@ -245,7 +245,7 @@ public:
         VideoWriter* writer = writers->operator[](range.start);
         CV_Assert(writer != NULL);
         CV_Assert(writer->isOpened());
-        
+
         Mat frame(CreateVideoWriterInvoker::FrameSize, CV_8UC3);
         for (unsigned int i = 0; i < FrameCount; ++i)
         {
@@ -253,7 +253,7 @@ public:
             writer->operator<< (frame);
         }
     }
-    
+
 protected:
     static std::string to_string(unsigned int i)
     {
diff --git a/modules/objdetect/src/matching.cpp b/modules/objdetect/src/matching.cpp
index 451fd03053..11873b1c28 100644
--- a/modules/objdetect/src/matching.cpp
+++ b/modules/objdetect/src/matching.cpp
@@ -1212,6 +1212,7 @@ int maxFunctionalScore(const CvLSVMFilterObject **all_F, int n,
         free(tmpPartsDisplacement[i]);
     }
     free(tmpPoints);
+    free(tmpPartsDisplacement);
     free(tmpScore);
     free(tmpKPoints);
 
diff --git a/modules/ocl/src/initialization.cpp b/modules/ocl/src/initialization.cpp
index 63916d9a58..a23900419c 100644
--- a/modules/ocl/src/initialization.cpp
+++ b/modules/ocl/src/initialization.cpp
@@ -615,7 +615,7 @@ namespace cv
                                                              CL_PROGRAM_BUILD_LOG, buildLogSize, buildLog, NULL));
                         cout << "\n\t\t\tBUILD LOG\n";
                         cout << buildLog << endl;
-                        delete buildLog;
+                        delete [] buildLog;
                     }
                     openCLVerifyCall(status);
                 }
diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp
index bc52f308c9..112967559a 100644
--- a/modules/python/src2/cv2.cpp
+++ b/modules/python/src2/cv2.cpp
@@ -224,9 +224,42 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
         return true;
     }
 
+    if( PyInt_Check(o) )
+    {
+        double v[] = {PyInt_AsLong((PyObject*)o), 0., 0., 0.};
+        m = Mat(4, 1, CV_64F, v).clone();
+        return true;
+    }
+    if( PyFloat_Check(o) )
+    {
+        double v[] = {PyFloat_AsDouble((PyObject*)o), 0., 0., 0.};
+        m = Mat(4, 1, CV_64F, v).clone();
+        return true;
+    }
+    if( PyTuple_Check(o) )
+    {
+        int i, sz = (int)PyTuple_Size((PyObject*)o);
+        m = Mat(sz, 1, CV_64F);
+        for( i = 0; i < sz; i++ )
+        {
+            PyObject* oi = PyTuple_GET_ITEM(o, i);
+            if( PyInt_Check(oi) )
+                m.at<double>(i) = (double)PyInt_AsLong(oi);
+            else if( PyFloat_Check(oi) )
+                m.at<double>(i) = (double)PyFloat_AsDouble(oi);
+            else
+            {
+                failmsg("%s is not a numerical tuple", info.name);
+                m.release();
+                return false;
+            }
+        }
+        return true;
+    }
+
     if( !PyArray_Check(o) )
     {
-        failmsg("%s is not a numpy array", info.name);
+        failmsg("%s is not a numpy array, neither a scalar", info.name);
         return false;
     }
 
@@ -236,6 +269,7 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
                typenum == NPY_BYTE ? CV_8S :
                typenum == NPY_USHORT ? CV_16U :
                typenum == NPY_SHORT ? CV_16S :
+               typenum == NPY_INT ? CV_32S :
                typenum == NPY_INT32 ? CV_32S :
                typenum == NPY_FLOAT ? CV_32F :
                typenum == NPY_DOUBLE ? CV_64F : -1;
@@ -245,7 +279,7 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
         if( typenum == NPY_INT64 || typenum == NPY_UINT64 || type == NPY_LONG )
         {
             needcopy = needcast = true;
-            new_typenum = NPY_INT32;
+            new_typenum = NPY_INT;
             type = CV_32S;
         }
         else
@@ -442,7 +476,12 @@ static bool pyopencv_to(PyObject* obj, int& value, const char* name = "<unknown>
     (void)name;
     if(!obj || obj == Py_None)
         return true;
-    value = (int)PyInt_AsLong(obj);
+    if(PyInt_Check(obj))
+        value = (int)PyInt_AsLong(obj);
+    else if(PyLong_Check(obj))
+        value = (int)PyLong_AsLong(obj);
+    else
+        return false;
     return value != -1 || !PyErr_Occurred();
 }
 
@@ -714,7 +753,14 @@ template<typename _Tp> struct pyopencvVecConverter
                 PyObject* item_ij = items_i[j];
                 if( PyInt_Check(item_ij))
                 {
-                    int v = PyInt_AsLong(item_ij);
+                    int v = (int)PyInt_AsLong(item_ij);
+                    if( v == -1 && PyErr_Occurred() )
+                        break;
+                    data[j] = saturate_cast<_Cp>(v);
+                }
+                else if( PyLong_Check(item_ij))
+                {
+                    int v = (int)PyLong_AsLong(item_ij);
                     if( v == -1 && PyErr_Occurred() )
                         break;
                     data[j] = saturate_cast<_Cp>(v);
diff --git a/modules/python/test/test2.py b/modules/python/test/test2.py
new file mode 100644
index 0000000000..c7491ad974
--- /dev/null
+++ b/modules/python/test/test2.py
@@ -0,0 +1,54 @@
+#/usr/bin/env python
+
+import unittest
+import random
+import time
+import math
+import sys
+import array
+import urllib
+import tarfile
+import hashlib
+import os
+import getopt
+import operator
+import functools
+import numpy as np
+import cv2
+import cv2.cv as cv
+
+class NewOpenCVTests(unittest.TestCase):
+
+    def get_sample(self, filename, iscolor = cv.CV_LOAD_IMAGE_COLOR):
+        if not filename in self.image_cache:
+            filedata = urllib.urlopen("https://raw.github.com/Itseez/opencv/master/" + filename).read()
+            self.image_cache[filename] = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor)
+        return self.image_cache[filename]
+
+    def setUp(self):
+        self.image_cache = {}
+
+    def hashimg(self, im):
+        """ Compute a hash for an image, useful for image comparisons """
+        return hashlib.md5(im.tostring()).digest()
+
+# Tests to run first; check the handful of basic operations that the later tests rely on
+
+class Hackathon244Tests(NewOpenCVTests):
+    
+    def test_int_array(self):
+        a = np.array([-1, 2, -3, 4, -5])
+        absa0 = np.abs(a)
+        self.assert_(cv2.norm(a, cv2.NORM_L1) == 15)
+        absa1 = cv2.absdiff(a, 0)
+        self.assert_(cv2.norm(absa1, absa0, cv2.NORM_INF) == 0)
+        
+    def test_imencode(self):
+        a = np.zeros((480, 640), dtype=np.uint8)
+        flag, ajpg = cv2.imencode("img_q90.jpg", a, [cv2.IMWRITE_JPEG_QUALITY, 90])
+        self.assert_(flag == True and ajpg.dtype == np.uint8 and ajpg.shape[0] > 1 and ajpg.shape[1] == 1)
+
+if __name__ == '__main__':
+    print "testing", cv.__version__
+    random.seed(0)
+    unittest.main()