Refactoring Barnes-Hut