fixed "type" error for errno, and potential error on lastid()