Upgraded filtering, code cleanup.