cleanup, speed improvements