fixing some errors, todos for deduping