Reduce db weight

This should implement issue #68.

Broad testing is very difficult, so I expect there might be some issues (but they shouldn't be that difficult to fix).