Implement offline mode. Closes #1241

Tested and works.