port fix + better error handling