Refactorized datalayer: separate concerns, improve readibility a bit.

Still, find() is a mess.