fix internal API mis-use and other small fixes
This will create a new commit in order to revert the existing changes.