I reordered the code in a more clean an organized way. Also this improves a lot the emacs startup time again, bucause after some updates it becomes a bit slow with the old configuration, so i did it again in a new way.