error checking, style fixes