Fix minor bugs and add example in the docs