Merged Sebastian's changes with send loop bugfix