Performance improvements

Some progress on #87