code cleanup and code style (PSR-2) fixes