Fix compile error, and some more code modifications

Signed-off-by: Francis Galiegue <fgaliegue@gmail.com>