Re-rolled patch #74. Please review. fixed the custom command failed.