ban.cpp refactoring

Some refactoring of ban.cpp.