Fix a lot of small bugs with partitioning. Add more tests. Version 0.0.5