Fixed type mismatch bugs