Just a quick stab at the basic functionality - no tests!