it was difficult to get comfortable in the cramped confines of the cage , but by lying on his back , with his legs braced against the bars and his neck crooked in the corner , he managed a few hours sleep .