several improvments and a lot of things changed
Fix conflict and make the code cleaner