Fixed library issue and a cleaned up some of the code.