Made changes to some of the php and javascript code