Well, the existing code handled this much better. It would always choose one of the sides of the solid block to place on, even if it technically could be the wrong one if you were very very close to the corner (not that you would ever notice). This code sticks it in the air, attached to nothing.