refactor for commonality and fixes #14