Fixed bugs discovered when building API example programs