few minor tweaks as I've rushed with the previous pull

Added validation and some minor changes. Hope I won't need to touch PHP in the closest future ;-)