Make runGetState more efficient, especially if called many times.

Issue #23. Needs to be done for more functions in this module.