Better ptree

Fixed the duplication bug
*and* allowing spaces in queries.