api code cleanup