The initialization code here is Andrej Mitrovic's idea from the D n.g.