Database model

* Partial revert of previous code dropping
Merge branch 'dev' of ssh://github.com/just-paja/pwf into dev