REVIEW [NX-390] misc refactoring for osgi

Extracted the refactoring changes out of #538 for easier reviewing/integration (plus some follow-up refactoring).