major attempt at AMD setup, and some re-factoring