Added examples
Some small changes and optimization.