Fixed wrap_lib

Addressed all comments from the previous PR from Tom. Closed that PR and opened this one. Contains the completely updated and corrected wrap_lib.py module.