Added graceful failure for json requests. Resolves #36