WORKING, LIB MODIFIED FOR AMD COMPATIBILITY