Resolved some conflicts left by abdoui's refactoring