fix aliasing violations and add some device optimizations