fixed many gotchas at once