Extra check so not to silently fail is no ports are available.
Improved behaviour for commands with no data block.
Added requirements/testing comments.