diff --git a/HOpenCV.cabal b/HOpenCV.cabal
--- a/HOpenCV.cabal
+++ b/HOpenCV.cabal
@@ -1,5 +1,5 @@
 name: HOpenCV
-version: 0.1.2
+version: 0.1.2.1
 license: BSD3
 maintainer: Noam Lewis <jones.noamle@gmail.com>
 bug-reports: mailto:jones.noamle@gmail.com
@@ -37,23 +37,22 @@
       AI.CV.OpenCV.CxCore
       AI.CV.OpenCV.HighGui
       AI.CV.OpenCV.Types
-      Foreign.ForeignPtrWrap
    c-sources:
       src/AI/CV/OpenCV/HOpenCV_wrap.c
    hs-Source-Dirs: src
    include-dirs: /usr/include/opencv
    extra-libraries: cv,highgui
-   build-depends: base >= 3 && < 5
-   ghc-options: -Wall
+   build-depends: base >=4 && <5, allocated-processor, vector-space
+   ghc-options: -Wall -fno-warn-type-defaults
 
 executable test-hopencv
   c-sources:
      src/AI/CV/OpenCV/HOpenCV_wrap.c
   include-dirs: /usr/include/opencv
   hs-source-dirs:  src
-  Build-Depends: base >= 4
+  Build-Depends: base >=4 && <5
   main-is: Test.hs
-  Ghc-Options: -Wall 
+  Ghc-Options: -Wall -fno-warn-type-defaults
   Ghc-Prof-Options:  -prof -auto-all 
   extra-libraries: cv,highgui
   other-modules: AI.CV.OpenCV.CxCore, AI.CV.OpenCV.CV, AI.CV.OpenCV.HighGui, AI.CV.OpenCV.Types
diff --git a/src/AI/CV/OpenCV/CxCore.hsc b/src/AI/CV/OpenCV/CxCore.hsc
--- a/src/AI/CV/OpenCV/CxCore.hsc
+++ b/src/AI/CV/OpenCV/CxCore.hsc
@@ -1,4 +1,4 @@
-{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-}
+{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls, TypeFamilies #-}
 
 module AI.CV.OpenCV.CxCore where
 
@@ -7,11 +7,18 @@
 import Foreign.C.String
 import Foreign
 
+import Data.VectorSpace as VectorSpace
 
 #include <cxcore.h>
 
 ------------------------------------------------------
+toFromIntegral :: (RealFrac c, Integral b, Integral a, Num b1) => (b1 -> c) -> a -> b
+toFromIntegral f = round . f . fromIntegral
 
+toFromIntegral2 :: (Integral a, Num b, Integral a1, Num b1, RealFrac a2, Integral b2) => (b -> b1 -> a2) -> a -> a1 -> b2
+toFromIntegral2 f x y = round (f (fromIntegral x) (fromIntegral y))
+------------------------------------------------------
+
 data CvSize  = CvSize { sizeWidth :: CInt, sizeHeight :: CInt }
                deriving (Show, Eq)
 instance Storable CvSize where
@@ -25,6 +32,24 @@
         (#poke CvSize, width) ptr w
         (#poke CvSize, height) ptr h
 
+liftCvSize ::(RealFrac c, Num b) => (b -> c) -> CvSize -> CvSize
+liftCvSize f (CvSize w h) = CvSize (f' w) (f' h)
+    where f' = toFromIntegral f
+
+liftCvSize2 :: (Num b, Num b1, RealFrac a) => (b -> b1 -> a) -> CvSize -> CvSize -> CvSize
+liftCvSize2 f (CvSize w1 h1) (CvSize w2 h2) = CvSize (f' w1 w2) (f' h1 h2)
+    where f' = toFromIntegral2 f
+
+instance AdditiveGroup CvSize where
+  zeroV = CvSize 0 0
+  (^+^) = liftCvSize2 (+)
+  negateV = liftCvSize (0-)
+
+instance VectorSpace CvSize where
+  type Scalar CvSize = Double -- todo: use CInt instead of Double here?
+  a *^ s = liftCvSize (a*) s
+
+
 data CvRect  = CvRect { rectX :: CInt, rectY :: CInt, rectWidth :: CInt, rectHeight :: CInt }
                deriving (Show, Eq)
                         
@@ -42,6 +67,26 @@
         (#poke CvRect, y) ptr y
         (#poke CvRect, width) ptr w
         (#poke CvRect, height) ptr h
+        
+
+liftCvRect :: (RealFrac c, Num b) => (b -> c) -> CvRect -> CvRect
+liftCvRect f (CvRect x y w h) = CvRect (f' x) (f' y) (f' w) (f' h)
+    where f' = toFromIntegral f
+
+liftCvRect2 :: (Num b, Num b1, RealFrac a) => (b -> b1 -> a) -> CvRect -> CvRect -> CvRect
+liftCvRect2 f (CvRect x1 y1 w1 h1) (CvRect x2 y2 w2 h2) = CvRect (f' x1 x2) (f' y1 y2) (f' w1 w2) (f' h1 h2)
+    where f' = toFromIntegral2 f
+
+instance AdditiveGroup CvRect where
+  zeroV = CvRect 0 0 0 0
+  (^+^) = liftCvRect2 (+)
+  negateV = liftCvRect (0-)
+
+instance VectorSpace CvRect where
+  type Scalar CvRect = Double -- todo: use CInt instead of Double here?
+  a *^ r = liftCvRect (a*) r
+  
+
 
 ------------------------------------------------------
 class IplArrayType a
diff --git a/src/Foreign/ForeignPtrWrap.hs b/src/Foreign/ForeignPtrWrap.hs
deleted file mode 100644
--- a/src/Foreign/ForeignPtrWrap.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-module Foreign.ForeignPtrWrap where
-
-import Foreign.Ptr
-import Foreign.ForeignPtr
-
-import System.IO.Error
-
--- A wrapper for newForeignPtr that handles nullPtrs, and can be chained to an IO Ptr creator.
--- usage:
--- myPtrCreator = (createForeignPtr deallocFunc) . allocFunc
--- where, allocFunc :: a->b->c->...-> IO (Ptr z)
-createForeignPtr :: (FunPtr (Ptr a -> IO () )) -> IO (Ptr a) -> IO (ForeignPtr a)
-createForeignPtr dealloc allocedPtr = do
-    ptr <- checkPtr allocedPtr
-    newForeignPtr dealloc ptr
-
-
-checkPtr :: IO (Ptr a) -> IO (Ptr a)
-checkPtr x = do 
-  res <- x
-  if res /= nullPtr 
-    then return res 
-    else fail "Null Pointer"
-
-------------------------------------------------
-errorName :: String -> IO a -> IO a
-errorName = modifyIOError . const . userError
-
-
