Code based on or inspired by Magnus Hetlands "Beginning Python"