UPDATED: Moved bucket helpers to bucket.go. Started fixing Update. TODO: slice manipulation needs to be tested for edge cases. A lot of out of bounds indexing errors occur here