added join column optimization, fix joins