Added clamp-function.