Fixed type checking (see github issue #16)