Some tutorial code with fixes