Implemented bucket functions, and other fixes