bug fixes/speed improvements