More fixes and lots of renaming of function names according to PSR-1 and 2 standard.