Fixed corrupted JSON response in API due to variable scoping
Properly return errors from mapReduce function for alias compliation