Performance improvements

fixes #17