Integeration of mem stage. bug fixes. testing