Nasty code for tutorial examples. Brace yourself ;p