Major database changes

For some reason I stuck to that design for a while before
realizing how this is bad database design and there's no
reason to do it this way.

Version bumped up to 3.1 as a result of this change.