increase code readability

Most changes are optical
Replaced on ereg with preg_match,