Make improvements suggested by @mgold