GPU Optimizations

Removed copy of gpu output to cpu and replaced it with a shared
buffer. Additional code cleanup is done as well.