Cleaning up the code and making it PSR1/2 compatible