documentation and code reduction

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

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

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