re-wrote a few unsafe functions with Maybe.