Api overhaul

Preliminary GPU support.