Added source code as well as an example.