Refactor database code for IPBans