Imprvements based on @lenary's comments in issue #1