Made API constants be class constants. Moved some functions from api to functions.inc.php