fix err handling and lib filename