Fixes from PR comments

- Moved $exists into static
- Renamned method that creates SQL for $exists clause
- Moved some logic around