Merge pull request #36 from lioncash/generic-clamp-function Introduce a generic clamp function to clean up some of the various 'if-else' clamps throughout parts of the codebase.