speed improvements and updated tests
speed improvements and updated tests