Wall checking functionality (+misc cleanup)