Fixed error handle, check for nulls.