fixed segfault in amd implmentation
Merge pull request #19 from csherratt/memory_rework

Major refactoring