Major refactoring

- Back porting `data.select()` from `pre-4.0` branch, lowering complexity to `O(n)`