Cleaned the code and made it a little bit more compatible with futur changes.