Some refactoring for flexibility + fix warnings