Separated metadata and real data to separated buckets.
Mode metadata implementation to its own module. Made
some API functions clearer.