Fix bugs with the Rakefile and build script