made some changes, fix some pitfalls, remove PHP_EOL