Fix type checking. Inspiration was taken from the Ruby SWIG Module