Was refactored again. Ready for use in test mode.