minor refactoring and entry point fixes