Lots of error fixes