fixed various issues with aliasing and where parsing. fixed issue 2