Add support for bucket types

This is WIP, do not merge yet.