Added Utility.js

This resolves #20 by moving duplicated functions over to utility.js and
providing general cleanup of code.