Refactor to use AMD. Overhaul build process.