Add clear() function to module

In most cases use the specific clear command, and for a couple of cases
fall back to copying an empty string.