Fixed some bugs and made minor updates to the backend scripts.
(Give read/write permission to users on the 'var' directory to avoid 500)