Fixed a few bugs in the api

I added a few explanatory comments and (hopefully) fixed some bugs, both unnoticeable and rather... game ending bugs... This is also where I assume the game crashes at, but thats only due to the fact that all file I/O is handled here...