couple of bug fixes and speed improvements