Significantly tighten up code for rake api tasks.