performance improvements (thx @m0nstermind)

from pull request #110