cleanup and make improvements

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