Refactored and added AMD support