Code refactoring: use the new run_cmd and avoid code duplication. Fixed double carriage return when returning results. Added new blocking command mode - useful in some cases (not used for now)