Added working code with some tests and demo data.