changes to bsp generation

some refactoring too