Cleanup of rake task
Added some error handling