code cleanup and module building, added LOG CLEAR function