Working outline of functionality + basic tests.