Adding code examples for tutorials, plus bug fixes.