Added basic API support, Fixed a few integrity bugs.