reorganize API code (bug 940398)
Merge pull request #2039 from washort/api-cleanup

reorganize API code (bug 940398)