Rebase of #141.

Signed-off-by: Gaetan Semet <gaetan@xeberon.net>