Fixed scoping bug with PyQuery references