Moved things to lib
Fixed bucket behavior