Changes to fix problems in #156

Signed-off-by: Luca Degasperi <luca@lucadegasperi.com>