Fix a bug while casting long to int. And refactor BlockingChannel to a interface.