Fixed warnings and possible errors