Fix bug where aliases weren't used for join criteria