Refactor process mechanism - needs work
Add db state save functionality