Lots more type fixes, hopefully no new bugs
Feel free to retarget to develop if that makes more sense
develop