Refactor bin/cask

I refactored bin/cask to improve structuring and documenation.  Most
notably, all functions have docstrings now.