Refactors cpu implementation
Adds structure for gpu implementation