Refactor based on feedback from V8 team