increase code readability

Most changes are optical (replacing tabs to spaces, and use proper indents)
Replaced one ereg with preg_match,