Rewrote a MAJOR part of the code. We should now have an API!