It lost more than half of its territory to Belgium in 1839 but gained a larger measure of autonomy .