fix bugs caused/found by mitch