lots of type and warning fixes