Fixed PSR warnings and bug