diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+### 2.2.2
+
+- Support for GHC 8.2.1 (#52)
+- Fixing errors with hidden contexts
+- Fixing GLSL link error on subtracting a negative constant (#55)
+- Fixing GLSL ambiguous overload with "clamp" (#51)
+- Adding atan2' (#44)
+
 ### 2.2.1
 
 - Render monad would crash if using deleted windows, when that should be a no-op. (#41).
diff --git a/GPipe.cabal b/GPipe.cabal
--- a/GPipe.cabal
+++ b/GPipe.cabal
@@ -1,61 +1,61 @@
-name:           GPipe
-version:        2.2.1
-cabal-version:  >= 1.8
-build-type:     Simple
-author:         Tobias Bexelius
-license:        MIT
-license-file:   LICENSE
-copyright:      Tobias Bexelius
-category:       Graphics
-stability:      Experimental
-synopsis:       Typesafe functional GPU graphics programming
-homepage:       https://github.com/tobbebex/GPipe-Core#readme
-bug-reports:    https://github.com/tobbebex/GPipe-Core/issues
-description:
-                A typesafe API based on the conceptual model of OpenGl, but without the imperative state machine.
-                Aims to be as close to the raw OpenGl performance as possible, without compromising type safety or functional style.
-                Includes DSL for shaders to provide type safety even when crossing into that domain.
-                Uses OpenGl 3.3 core profile under the hood.
-maintainer:     Tobias Bexelius
-data-files:     CHANGELOG.md
-
-library
-  hs-source-dirs:   src
-  build-depends:    base >= 4.9 && < 4.10,
-                    transformers >= 0.5.2 && < 0.6,
-                    exception-transformers >= 0.3 && < 0.5,
-                    containers >= 0.5 && < 0.6,
-                    Boolean >= 0.2 && <0.3,
-                    hashtables >= 1.2 && < 1.3,
-                    gl >= 0.8 && < 0.9,
-                    linear >= 1.18 && < 1.21
-  exposed-modules:
-                    Graphics.GPipe,
-                    Graphics.GPipe.Buffer,
-                    Graphics.GPipe.Context,
-                    Graphics.GPipe.Expr,
-                    Graphics.GPipe.Format,
-                    Graphics.GPipe.FragmentStream,
-                    Graphics.GPipe.FrameBuffer,
-                    Graphics.GPipe.PrimitiveArray,
-                    Graphics.GPipe.PrimitiveStream,
-                    Graphics.GPipe.Sampler,
-                    Graphics.GPipe.Shader,
-                    Graphics.GPipe.Texture,
-                    Graphics.GPipe.Uniform,
-                    Graphics.GPipe.Orphans
-  other-modules:
-                    Data.SNMap,
-                    Graphics.GPipe.Internal.Buffer,
-                    Graphics.GPipe.Internal.Compiler,
-                    Graphics.GPipe.Internal.Context,
-                    Graphics.GPipe.Internal.Expr,
-                    Graphics.GPipe.Internal.Format,
-                    Graphics.GPipe.Internal.FragmentStream,
-                    Graphics.GPipe.Internal.FrameBuffer,
-                    Graphics.GPipe.Internal.PrimitiveArray,
-                    Graphics.GPipe.Internal.PrimitiveStream,
-                    Graphics.GPipe.Internal.Shader,
-                    Graphics.GPipe.Internal.Texture,
-                    Graphics.GPipe.Internal.Uniform,
-                    Graphics.GPipe.Internal.Orphans
+name:           GPipe
+version:        2.2.2
+cabal-version:  >= 1.8
+build-type:     Simple
+author:         Tobias Bexelius
+license:        MIT
+license-file:   LICENSE
+copyright:      Tobias Bexelius
+category:       Graphics
+stability:      Experimental
+synopsis:       Typesafe functional GPU graphics programming
+homepage:       https://github.com/tobbebex/GPipe-Core#readme
+bug-reports:    https://github.com/tobbebex/GPipe-Core/issues
+description:
+                A typesafe API based on the conceptual model of OpenGl, but without the imperative state machine.
+                Aims to be as close to the raw OpenGl performance as possible, without compromising type safety or functional style.
+                Includes DSL for shaders to provide type safety even when crossing into that domain.
+                Uses OpenGl 3.3 core profile under the hood.
+maintainer:     Tobias Bexelius
+data-files:     CHANGELOG.md
+
+library
+  hs-source-dirs:   src
+  build-depends:    base >= 4.9 && < 4.11,
+                    transformers >= 0.5.2 && < 0.6,
+                    exception-transformers >= 0.3 && < 0.5,
+                    containers >= 0.5 && < 0.6,
+                    Boolean >= 0.2 && <0.3,
+                    hashtables >= 1.2 && < 1.3,
+                    gl >= 0.8 && < 0.9,
+                    linear >= 1.18 && < 1.21
+  exposed-modules:
+                    Graphics.GPipe,
+                    Graphics.GPipe.Buffer,
+                    Graphics.GPipe.Context,
+                    Graphics.GPipe.Expr,
+                    Graphics.GPipe.Format,
+                    Graphics.GPipe.FragmentStream,
+                    Graphics.GPipe.FrameBuffer,
+                    Graphics.GPipe.PrimitiveArray,
+                    Graphics.GPipe.PrimitiveStream,
+                    Graphics.GPipe.Sampler,
+                    Graphics.GPipe.Shader,
+                    Graphics.GPipe.Texture,
+                    Graphics.GPipe.Uniform,
+                    Graphics.GPipe.Orphans
+  other-modules:
+                    Data.SNMap,
+                    Graphics.GPipe.Internal.Buffer,
+                    Graphics.GPipe.Internal.Compiler,
+                    Graphics.GPipe.Internal.Context,
+                    Graphics.GPipe.Internal.Expr,
+                    Graphics.GPipe.Internal.Format,
+                    Graphics.GPipe.Internal.FragmentStream,
+                    Graphics.GPipe.Internal.FrameBuffer,
+                    Graphics.GPipe.Internal.PrimitiveArray,
+                    Graphics.GPipe.Internal.PrimitiveStream,
+                    Graphics.GPipe.Internal.Shader,
+                    Graphics.GPipe.Internal.Texture,
+                    Graphics.GPipe.Internal.Uniform,
+                    Graphics.GPipe.Internal.Orphans
diff --git a/src/Graphics/GPipe/Internal/Context.hs b/src/Graphics/GPipe/Internal/Context.hs
--- a/src/Graphics/GPipe/Internal/Context.hs
+++ b/src/Graphics/GPipe/Internal/Context.hs
@@ -162,10 +162,6 @@
 registerRenderWriteTexture :: Int -> Render os ()
 registerRenderWriteTexture n = Render $ lift $ lift $ modify $ \ rs -> rs { renderWriteTextures = Set.insert n $ renderWriteTextures rs }
 
-
---newBoundState = BoundState Map.empty Map.empty (-1)
-
-
 instance MonadTrans (ContextT ctx os) where
     lift = ContextT . lift . lift
 
@@ -181,7 +177,7 @@
        mapM_ snd cds' -- Delete all windows not explicitly deleted
        contextHandlerDelete ctx
      )
-     (\ctx -> evalStateT (runReaderT m (ContextEnv ctx cds)) (ContextState 1 IMap.empty 0))
+     (\ctx -> evalStateT (runReaderT m (ContextEnv ctx cds)) (ContextState 1 IMap.empty (-1)))
 
 data Window os c ds = Window { getWinName :: Name }
 
@@ -195,7 +191,7 @@
   w <- liftIO $ createContext ctx Nothing
   cd <- liftIO $ addContextData (contextDelete ctx w) cds
   let ws = WindowState cd IMap.empty IMap.empty (-1)
-  lift $ put $ ContextState wid (IMap.singleton wid (ws,w)) 0
+  lift $ put $ ContextState wid (IMap.singleton 0 (ws,w)) 0
   liftIO $ contextDoAsync ctx (Just w) initGlState
   return w
 
@@ -224,7 +220,7 @@
       n' <- if (IMap.null wmap')
               then do
                 void $ let ContextT m = createHiddenWin in m -- Create a hidden window before we delete last window
-                return 0 -- The hidden window is now Concurrent
+                return 0 -- The hidden window is now Current
               else if n /= wid then return n
                                else return (fst (head (IMap.toList wmap'))) -- always at least one elem
       liftIO $ do removeContextData cds (windowContextData ws)
@@ -306,13 +302,6 @@
 withContextWindow (Window wid) m = ContextT $ do
   wmap <- lift $ gets perWindowState
   liftIO $ m (snd <$> IMap.lookup wid wmap)
-
-{-}
--- | This is only used to finalize nonShared objects such as VBOs and FBOs
-getRenderContextFinalizerAdder  :: Render os (IORef a -> IO () -> IO ())
-getRenderContextFinalizerAdder = do f <- Render (lift $ lift $ asks fst)
-                                    return $ \k m -> void $ mkWeakIORef k (f True m)
--}
 
 -- | This kind of exception may be thrown from GPipe when a GPU hardware limit is reached (for instance, too many textures are drawn to from the same 'FragmentStream')
 data GPipeException = GPipeException String
diff --git a/src/Graphics/GPipe/Internal/Expr.hs b/src/Graphics/GPipe/Internal/Expr.hs
--- a/src/Graphics/GPipe/Internal/Expr.hs
+++ b/src/Graphics/GPipe/Internal/Expr.hs
@@ -530,7 +530,7 @@
 
 instance Fractional (S a Float) where
   (/)          = binf "/"
-  fromRational = S . return . show . (`asTypeOf` (undefined :: Float)) . fromRational
+  fromRational = S . return . ("float(" ++) . (++ ")") . show . (`asTypeOf` (undefined :: Float)) . fromRational
 
 class Integral' a where
     div' :: a -> a -> a
@@ -642,6 +642,7 @@
   fract' :: a -> a
   mod'' :: a -> a -> a
   mix :: a -> a -> a-> a
+  atan2' :: a -> a -> a
 
   rsqrt = (1/) . sqrt
   exp2 = (2**)
@@ -652,15 +653,17 @@
   floor' x = -ceiling' (-x)
   ceiling' x = -floor' (-x)
 
-  {-# MINIMAL floor' | ceiling' #-}
+  {-# MINIMAL (floor' | ceiling') , atan2' #-}
 
 instance Real' Float where
   floor' = fromIntegral . floor
   ceiling' = fromIntegral . ceiling
+  atan2' = atan2
 
 instance Real' Double where
   floor' = fromIntegral . floor
   ceiling' = fromIntegral . ceiling
+  atan2' = atan2
 
 instance Real' (S x Float) where
   rsqrt = fun1f "inversesqrt"
@@ -671,6 +674,7 @@
   fract' = fun1f "fract"
   mod'' = fun2f "mod"
   mix = fun3f "mix"
+  atan2' = fun2f "atan"
 
 instance (Real' a) => Real' (V0 a) where
   rsqrt = liftA rsqrt
@@ -681,6 +685,7 @@
   fract' = liftA fract'
   mod'' = liftA2 mod''
   mix = liftA3 mix
+  atan2' = liftA2 atan2'
 instance (Real' a) => Real' (V1 a) where
   rsqrt = liftA rsqrt
   exp2 = liftA exp2
@@ -690,6 +695,7 @@
   fract' = liftA fract'
   mod'' = liftA2 mod''
   mix = liftA3 mix
+  atan2' = liftA2 atan2'
 instance (Real' a) => Real' (V2 a) where
   rsqrt = liftA rsqrt
   exp2 = liftA exp2
@@ -699,6 +705,7 @@
   fract' = liftA fract'
   mod'' = liftA2 mod''
   mix = liftA3 mix
+  atan2' = liftA2 atan2'
 instance (Real' a) => Real' (V3 a) where
   rsqrt = liftA rsqrt
   exp2 = liftA exp2
@@ -708,6 +715,7 @@
   fract' = liftA fract'
   mod'' = liftA2 mod''
   mix = liftA3 mix
+  atan2' = liftA2 atan2'
 instance (Real' a) => Real' (V4 a) where
   rsqrt = liftA rsqrt
   exp2 = liftA exp2
@@ -717,6 +725,7 @@
   fract' = liftA fract'
   mod'' = liftA2 mod''
   mix = liftA3 mix
+  atan2' = liftA2 atan2'
 
 -- | This class provides various order comparing functions
 class (IfB a, OrdB a, Floating a) => FloatingOrd a where
diff --git a/src/Graphics/GPipe/Internal/Format.hs b/src/Graphics/GPipe/Internal/Format.hs
--- a/src/Graphics/GPipe/Internal/Format.hs
+++ b/src/Graphics/GPipe/Internal/Format.hs
@@ -215,8 +215,6 @@
 
 instance TextureFormat Depth where
     getGlFormat _ = GL_DEPTH_COMPONENT
-instance TextureFormat Stencil where
-    getGlFormat _ = GL_STENCIL_INDEX
 instance TextureFormat DepthStencil where
     getGlFormat _ = GL_DEPTH_STENCIL
 
@@ -367,7 +365,7 @@
     clearColor :: c -> Color c (ColorElement c) -> IO ()
     clearColor = error "You cannot create your own instances of ColorRenderable"
 class ColorSampleable f => DepthRenderable f
-class TextureFormat f => StencilRenderable f
+class StencilRenderable f
 
 instance ColorRenderable RFloat where
     clearColor _ r = withArray [realToFrac r, 0,0,0] (glClearBufferfv GL_COLOR 0)
