Fix Cast functions, and added cast to boolean