add examples and misc bugfixes