Refactor the Rakefile.

This commit fixes #247.
Merge branch 'id/247' into dev