Improve code
Add popup support
Add criteria support