Added logging and made sending input more efficient