Completed sql-alias implementation. Just need to rebase and review.