translate stuff to functions

Signed-off-by: Mattias Andrée <maandree@operamail.com>
translate stuff to functions

Signed-off-by: Mattias Andrée <maandree@operamail.com>
read add outputs

Signed-off-by: Mattias Andrée <maandree@operamail.com>