some bug fixes and example