Add logging features and fix persistor issues
Add reference mechanism support. Small refactoring.
Add some unit tests