Completed initial implementation of bucketing algorithm. No testing yet.