Refactoring, better debug printing.
Formating.
Bug fix: node loaded from database should be in CREATED state, removed debug print.