Thank you for writing in, Your version of X (5.1.1) and Cornerstone (3.1.6) is not compatible, this is more likely the culprit of your issues. Please update your X and Cornerstone to the latest version (6.2.5 and 3.2.5 respectively), you can check what are the latest compatible versions here.
You can follow the updating methods provided here.
Remember to clear all caches (plugin, server-side, CDN, and browser's cache) after updating so that the code from the latest release is always in use. This will help you to avoid any potential errors.
Let us know how it goes,