AMD support

Here's an AMD wrapper with minimal changes to the code structure.