--- a/scripts/chanact.pl
+++ b/scripts/chanact.pl
@@ -207,6 +207,13 @@
 	$item->default_handler($get_size_only, $actString, undef, 1);
 }
 
+sub chan_sort {
+       my ($an, $bn) = ($a->get_active_name, $b->get_active_name);
+       return -1 if $an !~ /^[#&]/ and $bn =~ /^[#&]/;
+       return 1 if $an =~ /^[#&]/ and $bn !~ /^[#&]/;
+       return $a->{refnum} <=> $b->{refnum};
+}
+
 # this is the real creation method
 sub remake() {
 	my ($afternumber,$finish,$hilight,$mode,$number,$display,@windows);
@@ -214,12 +221,15 @@
 	my $abbrev = Irssi::settings_get_int('chanact_abbreviate_names');
 	my $remove_prefix = Irssi::settings_get_str('chanact_remove_prefix');
 	my $remove_hash = Irssi::settings_get_bool('chanact_remove_hash');
+        my %level_list = map { /(.*):(.*)/ ? ($1, $2) : ($_, 1) }
+          split (/\s+/, Irssi::settings_get_str("chanact_ignore_level"));
+        my $data_level = Irssi::settings_get_int('chanact_data_level');
 
  	if (Irssi::settings_get_bool('chanact_sort_by_activity')) {
 		@windows = sort { ($b->{last_line} <=> $a->{last_line}) }
 			Irssi::windows;
 	} else {
-		@windows = sort { ($a->{refnum}) <=> ($b->{refnum}) }
+		@windows = sort chan_sort
 			Irssi::windows;
 	}
 
@@ -229,6 +239,10 @@
 		# since irssi is single threaded this shouldn't happen
 		!ref($win) && next;
 
+                if ($win->{data_level} < ($level_list{$name} || $data_level)) {
+                  next;
+                }
+
 		my $active = $win->{active};
 		!ref($active) && next;
 
@@ -438,6 +452,8 @@
 Irssi::settings_add_bool('chanact', 'chanact_chop_status', 1);
 Irssi::settings_add_bool('chanact', 'chanact_sort_by_activity', 1);
 Irssi::settings_add_int('chanact', 'chanact_filter', 0);
+Irssi::settings_add_int('chanact', 'chanact_data_level', 1);
+Irssi::settings_add_str('chanact', 'chanact_ignore_level', '');
 
 # register the statusbar item
 Irssi::statusbar_item_register('chanact', '$0', 'chanact');
