Fixing and cleaning

- Added missing specs
- Added missing PHPDocs
- Moved the code to the proper file
- Refactored and cleaned the code