fixed all type errors and warnings