Fixing things in API and rake task