cleanup, minimum value

I've cleaned up the code a bit and added support for minimum value in the lowest bucket.