Proof of concept; works, but has several hard-coded hacks.