Fixed some bugs, tables/subqueries can now generate aliases, fixed some tests