add programmatic examples, fix deprecated APIs