Fixed receive bug and more optimalizations