Implemented examples from book.