Native cleanup

Refactoring and cleanup