Changed data modeling.
Added some unit testing.