m fixes + use gpp to make it more maintainable

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