Fix some issues in code gen; Add some examples.