issue #72 - performance improvements; added some tests