Bugs fixed, added an example