Refactor and add documentation to BucketService