API overhaul

Doesn't work yet, for some reason I couldn't immediately figure out.