Library: Fixed resource leak