Refactoring of the code. Removed some more unnecessary things.