Bug fixes and example