Fomatted by PhpStorm, several fixed bugs