Improved some API functions and fixed a couple little bugs.