Refactored receiving algorythm. Again.