Refactor basalt to improve performance a little