Neatened code, and ready to put onto server