work against issue #50. Almost done, but still need some tuning