reformatting all code and fixing server side security issues