datastream api code cleanup