Fix various code style, behaviour and interface issues

Signed-off-by: Daniele Ricci <daniele.athome@gmail.com>