more layer separation in the model and cleaned up debug logging