-Under the hood, \cleaninline{liftmTask}:
-\begin{itemize}
- \item Generates a fresh task identifier for the device.
- \item Compiles the task and fetches the values for the tethered \glspl{SDS}.
- \item Sends the task to the device
- \item Watches, in parallel: the tethered \glspl{SDS} in \gls{ITASK}, if they are updated, a message is sent to the device; the \gls{SDS} update queue, if there is a downstream update, the \gls{ITASK} \gls{SDS} it references is updated as well; and the task value.
-\end{itemize}
-
-The task value of the \cleaninline{liftmTask} task is the task value of the task on the edge device.
-
-\todo{v.b.\ voor liftmtask}
-
-\section{Lifting \texorpdfstring{\gls{ITASK}}{iTask} \texorpdfstring{\glsxtrlongpl{SDS}}{shared data sources}}\label{sec:liftsds}
-Lifting \gls{ITASK} \glspl{SDS} to \gls{MTASK} \glspl{SDS} is something that mostly happens at the compiler level using the \cleaninline{liftsds} function (see \cref{lst:mtask_itasksds}).
-\Glspl{SDS} in \gls{MTASK} must always have an initial value.
-For regular \gls{SDS} this value is given in the source code, for lifted \gls{ITASK} \glspl{SDS} this value is obtained by reading the values once just before sending the task to the edge device.
-On the device itself, there is just one difference between lifted \glspl{SDS} and regular \glspl{SDS}: after changing \pgls{SDS}, a message is sent to the server containing this new value.
+\Cref{lst:liftmTask_pseudo} shows the pseudocode for the \cleaninline{liftmTask} implementation
+The first argument is the task and the second argument is the device which is an \gls{ADT} containing the \glspl{SDS} referring to the device information, the \gls{SDS} update queue, and the channels.
+First a fresh identifier for the task is generated using the device state.
+With this identifier, the cleanup hook can be installed.
+This is done to assure the task is removed from the edge device if the \gls{ITASK} task coordinating it is destroyed.
+Tasks in \gls{ITASK} are destroyed when for example it is executed in parallel with another task and the parallel combinator terminates, or when the condition to step holds in a sequential task combination.
+Then the \gls{MTASK} compiler is invoked, its only argument besides the task is a function doing something with the results of the compilation, i.e.\ the lowered \glspl{SDS} and the messages containing the compiled and serialised task.
+With the result of the compilation, the task can be executed.
+First the messages are put in the channels, sending them to the device.
+Then, in parallel:
+\begin{enumerate}
+ \item the value is watched by looking in the device state \gls{SDS}, this task also determines the task value of the whole task;
+ \item the downstream \glspl{SDS} are monitored, i.e.\ the \cleaninline{sdsupdates} \gls{SDS} is monitored and updates from the device are applied to the associated \gls{ITASK} \gls{SDS};
+ \item the upstream \glspl{SDS} are monitored by spawning tasks that watch these \glspl{SDS}, if one is updated, the novel value is sent to the edge device.
+\end{enumerate}
+
+\begin{lstClean}[label={lst:liftmTask_pseudo},caption={Pseudocode implementation for \texttt{liftmTask}.}]
+liftmTask task (MTDevice dev sdsupdates channels)
+ = freshTaskId dev
+ >>= \tid->withCleanupHook (sendmessage [MTTTaskDel tid] channels) (
+ compile task \mrefs msgs->
+ sendMessage msgs channels
+ >>| waitForReturnAndValue tid dev
+ -|| watchSharesDownstream mrefs tid sdsupdates
+ -|| watchSharesUpstream mrefs channels tid)
+\end{lstClean}
+
+Sending the complete byte code to the device is not always a suitable option.
+For example, when the device is connected through an unstable or slow connection, sending the entire byte code induces a lot of delay.
+To mitigate this problem, \gls{MTASK} tasks can be preloaded on a device.
+Preloading means that the task is compiled and integrated into the device firmware.
+On receiving a \cleaninline{TaskPrep}, a hashed value of the task to be sent is included.
+The device then checks the preloaded task registry and uses the local preloaded version if the hash matches.
+Of course this only works for tasks that are not tailor made for the current work specification and not depend on run time information.
+The interface for task preloading can be found in \cref{lst:preload}.
+Given an \gls{MTASK} task, a header file is created that should be placed in the source code directory of the \gls{RTS} before building to include it in the firmware.
+
+\begin{lstClean}[label={lst:preload},caption={Preloading tasks in \gls{MTASK}.}]
+preloadTask :: (Main (MTask BCInterpret a)) -> Task String
+\end{lstClean}
+
+\section{Lowering \texorpdfstring{\gls{ITASK}}{iTask} \texorpdfstring{\glsxtrlongpl{SDS}}{shared data sources}}\label{sec:liftsds}
+Lowering \gls{ITASK} \glspl{SDS} to \gls{MTASK} \glspl{SDS} is something that mostly happens at the \gls{DSL} level using the \cleaninline{lowerSds} function (see \cref{lst:mtask_itasksds}).
+Lowering \pgls{SDS} proxies the \gls{ITASK} \gls{SDS} for use in \gls{MTASK}.
+\Glspl{SDS} in \gls{MTASK} always have an initial value.
+For regular \gls{SDS} this value is given in the source code, for lowered \gls{ITASK} \glspl{SDS} this value is obtained by reading the values once just before sending the task to the edge device.
+On the device, there is just one difference between lowered \glspl{SDS} and regular \glspl{SDS}: after changing a lowered \gls{SDS}, a message is sent to the server containing this new value.