Additional refactoring for conforming to JSON API as well as input sanitization and error checks for searches.