set max messages, remove unused vars