I don't know how slow it would run, nor can I measure how much elegant this solution would be, but... I'm no programmer, so, I'm only giving it a try.
Why not using strings instead of numbers for the tile types. They would be four character strings, formed by 0 for an exit side and 1 for a blocked side using the format "top down left right", thus, "1110" would be a tile you can only exit through the right, while "1010" could be left by the bottom or the right.
In fact, as an afterthought, you could use decimal numbers and convert them to binary to get the coordinates if you like.
Anyway, I'm feeling I'm talking bulls**t, but, then, I may, luckily not...
When everything is catastrophic, thank the Gods things aren't worse!