Fixed type errors and warnings