few javascript and php improvements