diff --git a/csound-expression-dynamic.cabal b/csound-expression-dynamic.cabal
--- a/csound-expression-dynamic.cabal
+++ b/csound-expression-dynamic.cabal
@@ -1,5 +1,5 @@
 Name:          csound-expression-dynamic
-Version:       0.1.2
+Version:       0.1.3
 Cabal-Version: >= 1.6
 License:       BSD3
 License-file:  LICENSE
diff --git a/src/Csound/Dynamic/Build.hs b/src/Csound/Dynamic/Build.hs
--- a/src/Csound/Dynamic/Build.hs
+++ b/src/Csound/Dynamic/Build.hs
@@ -23,8 +23,9 @@
     setSr, setKsmps, setNchnls, setNchnls_i, setKr, setZeroDbfs
 ) where
 
-import qualified Data.Map as M(fromList)
+import qualified Data.Map as M(fromList, toList)
 
+import Data.List(transpose)
 import Data.Fix(Fix(..))
 
 import Csound.Dynamic.Types
@@ -45,8 +46,15 @@
 oprInfix name signature = Info name signature Infix
 
 tfm :: Info -> [E] -> E
-tfm info args = noRate $ Tfm info $ fmap toPrimOr args
+tfm info args = noRate $ Tfm info $ zipWith toPrimOrTfm (getInfoRates info) args
 
+getInfoRates :: Info -> [Rate]
+getInfoRates a = getInRates $ infoSignature a
+    where
+        getInRates x = case x of
+            SingleRate m    -> fmap minimum $ transpose $ fmap snd $ M.toList m
+            MultiRate _ ins -> ins
+
 tfmNoInlineArgs :: Info -> [E] -> E
 tfmNoInlineArgs info args = noRate $ Tfm info $ fmap (PrimOr . Right) args
 
@@ -177,12 +185,15 @@
     
 setZeroDbfs :: Monad m => Double -> DepT m  ()
 
-setSr       = gInit "sr"
-setKr       = gInit "kr"
-setNchnls   = gInit "nchnls"
-setNchnls_i = gInit "nchnls_i"
-setKsmps    = gInit "ksmps"
-setZeroDbfs = gInitDouble "0dbfs"
+setGlobal :: (Monad m, Show a) => String -> a -> DepT m  ()
+setGlobal name val = verbatim $ name ++ " = " ++ show val
+
+setSr       = setGlobal "sr"
+setKr       = setGlobal "kr"
+setNchnls   = setGlobal "nchnls"
+setNchnls_i = setGlobal "nchnls_i"
+setKsmps    = setGlobal "ksmps"
+setZeroDbfs = setGlobal "0dbfs"
 
 gInit :: Monad m => String -> Int -> DepT m ()
 gInit name val = writeVar (VarVerbatim Ir name) (int val)
diff --git a/src/Csound/Dynamic/Build/Logic.hs b/src/Csound/Dynamic/Build/Logic.hs
--- a/src/Csound/Dynamic/Build/Logic.hs
+++ b/src/Csound/Dynamic/Build/Logic.hs
@@ -3,7 +3,7 @@
 -- | Boolean instances
 module Csound.Dynamic.Build.Logic(
     when1, whens,
-    ifBegin, ifEnd, elseBegin, elseIfBegin,
+    ifBegin, ifEnd, elseBegin,
     untilDo,
     untilBegin, untilEnd
 ) where
@@ -33,14 +33,11 @@
         elseIfs as
         elseBegin 
         el
-        ifEnd
-    where elseIfs = mapM_ (\(p, body) -> elseIfBegin p >> body)
+        foldl1 (>>) $ replicate (1 + length as) ifEnd
+    where elseIfs = mapM_ (\(p, body) -> elseBegin >> ifBegin p >> body)
 
 ifBegin :: Monad m => E -> DepT m ()
 ifBegin = withCond IfBegin
-
-elseIfBegin :: Monad m => E -> DepT m ()
-elseIfBegin = withCond ElseIfBegin
 
 elseBegin :: Monad m => DepT m ()
 elseBegin = stmtOnlyT ElseBegin
diff --git a/src/Csound/Dynamic/Render/Instr.hs b/src/Csound/Dynamic/Render/Instr.hs
--- a/src/Csound/Dynamic/Render/Instr.hs
+++ b/src/Csound/Dynamic/Render/Instr.hs
@@ -44,7 +44,7 @@
 getFrameInfo x = case ratedExpExp x of
     -- Imperative If-then-else
     IfBegin _     -> StartFrame
-    ElseIfBegin _ -> NextFrame
+--     ElseIfBegin _ -> NextFrame
     ElseBegin     -> NextFrame 
     IfEnd         -> StopFrame
     -- looping constructions
@@ -169,7 +169,7 @@
     ExpPrim p -> ExpPrim p
     IfBegin _ -> rec2 condRate expr
     UntilBegin _ -> rec2 condRate expr
-    ElseIfBegin _ -> rec2 condRate expr
+--    ElseIfBegin _ -> rec2 condRate expr
     ElseBegin -> ElseBegin
     IfEnd -> IfEnd
     UntilEnd -> UntilEnd
diff --git a/src/Csound/Dynamic/Render/Pretty.hs b/src/Csound/Dynamic/Render/Pretty.hs
--- a/src/Csound/Dynamic/Render/Pretty.hs
+++ b/src/Csound/Dynamic/Render/Pretty.hs
@@ -116,7 +116,7 @@
     ReadVar v                       -> tab $ res $= ppVar v
 
     IfBegin a                       -> succTab          $ text "if "     <> ppCond a <> text " then"
-    ElseIfBegin a                   -> left >> (succTab $ text "elseif " <> ppCond a <> text " then")    
+--     ElseIfBegin a                   -> left >> (succTab $ text "elseif " <> ppCond a <> text " then")    
     ElseBegin                       -> left >> (succTab $ text "else")
     IfEnd                           -> left >> (tab     $ text "endif")
     UntilBegin a                    -> succTab          $ text "until " <> ppCond a <> text " do"
diff --git a/src/Csound/Dynamic/Types/Exp.hs b/src/Csound/Dynamic/Types/Exp.hs
--- a/src/Csound/Dynamic/Types/Exp.hs
+++ b/src/Csound/Dynamic/Types/Exp.hs
@@ -3,7 +3,7 @@
 module Csound.Dynamic.Types.Exp(
     E, RatedExp(..), isEmptyExp, RatedVar, ratedVar, ratedVarRate, ratedVarId, 
     ratedExp, noRate, withRate, setRate,
-    Exp, toPrimOr, PrimOr(..), MainExp(..), Name, 
+    Exp, toPrimOr, toPrimOrTfm, PrimOr(..), MainExp(..), Name, 
     InstrId(..), intInstrId, ratioInstrId, stringInstrId,
     VarType(..), Var(..), Info(..), OpcFixity(..), Rate(..), 
     Signature(..), isInfix, isPrefix,    
@@ -102,11 +102,24 @@
 toPrimOr :: E -> PrimOr E
 toPrimOr a = PrimOr $ case ratedExpExp $ unFix a of
     ExpPrim (PString _) -> Right a
-    ExpPrim p -> Left p
+    ExpPrim p  -> Left p
     ReadVar v | noDeps -> Left (PrimVar (varRate v) v)
     _         -> Right a
-    where noDeps = isNothing $ ratedExpDepends $ unFix a
+    where 
+        noDeps = isNothing $ ratedExpDepends $ unFix a
 
+-- | Constructs PrimOr values from the expressions. It does inlining in
+-- case of primitive values.
+toPrimOrTfm :: Rate -> E -> PrimOr E
+toPrimOrTfm r a = PrimOr $ case ratedExpExp $ unFix a of
+    ExpPrim (PString _) -> Right a
+    ExpPrim p | (r == Ir || r == Sr) -> Left p
+    ReadVar v | noDeps -> Left (PrimVar (varRate v) v)
+    _         -> Right a
+    where 
+        noDeps = isNothing $ ratedExpDepends $ unFix a
+
+
 -- Expressions with inlining.
 type Exp a = MainExp (PrimOr a)
 
@@ -133,7 +146,7 @@
     | WriteVar Var a    
     -- | Imperative If-then-else
     | IfBegin (CondInfo a)
-    | ElseIfBegin (CondInfo a)
+--  | ElseIfBegin (CondInfo a) -- It's expressed with nested if-else
     | ElseBegin
     | IfEnd
     -- | looping constructions
