Refactoring of the code. Fixed some commands. Removed some warnings.