Work in progress - working proof of concept; needs a tiny bit of tidying up though.