Added a strip function, added some error checking to a bunch of
the other functions incase one of the parameters is NULL or
another invalid vaule.