Made padRight() and padLeft() more safe for invalid arguments.