API: Fixed misc bugs. Changed db structure.