Fixed up a few bugs (code and conceptional) in the Rake tasks

See commits for details