Fixed crash when filtering. Removed some unused code