         {# call element_get_query_types #} (toElement element) >>=
             peekArray0 0
 
+-- | Perform a query on the given element.
+--   
+--   For elements that don't implement a query handler, this function
+--   forwards the query to a random srcpad or to the peer of a random
+--   linked sinkpad of this element.
 elementQuery :: (ElementClass element, QueryClass query)
-             => element
-             -> query
-             -> IO (Maybe query)
+             => element -- ^ @element@ - 
+             -> query   -- ^ @query@ - 
+             -> IO Bool -- ^ 'True' if the query could be performed
 elementQuery element query =
     do query' <- {# call mini_object_copy #} (toMiniObject query) >>=
                     newForeignPtr_ . castPtr
-       success <- {# call element_query #} (toElement element) $ Query query'
-       if toBool success
-           then liftM Just $ withForeignPtr query' $ takeMiniObject . castPtr
-           else return Nothing
-
+       fmap toBool $ {# call element_query #} (toElement element) $ Query query'
+
+-- | Query an element for the convertion of a value from one format to
+--   another.
 elementQueryConvert :: ElementClass element
-                    => element
-                    -> Format
-                    -> Int64
-                    -> IO (Maybe (Format, Word64))
-elementQueryConvert element srcFormat srcVal =
+                    => element -- ^ @element@ - the element to query
+                    -> Format  -- ^ @srcFormat@ - the format to convert from
+                    -> Int64   -- ^ @srcVal@ - the value to convert
+                    -> Format  -- ^ @destFormat@ - the format to convert to
+                    -> IO (Maybe (Format, Word64)) -- ^ the resulting format and value
+elementQueryConvert element srcFormat srcVal destFormat =
     alloca $ \destFormatPtr ->
         alloca $ \destValPtr ->
-            do success <- {# call element_query_convert #} (toElement element)
+            do poke destFormatPtr $ fromIntegral $ fromEnum destFormat
+               success <- {# call element_query_convert #} (toElement element)
                                                        (fromIntegral $ fromEnum srcFormat)
                                                        (fromIntegral srcVal)
                                                        destFormatPtr

                                          fromIntegral cur)
                   else return Nothing

elementQueryDuration :: ElementClass element
                     => element
                     -> Format
                     -> IO (Maybe (Format, Word64))
elementQueryDuration element format =
    alloca $ \formatPtr ->
        alloca $ \durationPtr ->

                                          fromIntegral destVal)
                   else return Nothing

-- | Query an element for its stream position.
elementQueryPosition :: ElementClass element
                     => element -- ^ @element@ - the element to query
                     -> Format  -- ^ @format@ - the format requested
                     -> IO (Maybe (Format, Word64)) -- ^ the resulting format and value
elementQueryPosition element format =
    alloca $ \formatPtr ->
        alloca $ \curPtr ->
