hopefully fixed 400 throttling error, also some minor code cleanup