Fiddling around with subs, io and data structures