Streamlined code a bit, see #56.