In recent months, North Korea has found itself at the centre of international attention. Its policies are once again described as "irrational" or "bizarre", and its hereditary leader Kim Jong-un is presented as an eccentric and irrational creature, fond of killing his relatives and threatening the world with nuclear weapons. But this description is misleading: Kim knows what he is doing.
In January, he said that his country came close to testing a long-range weapon delivery system, also known as an intercontinental ballistic missile (ICBM), which, as it was implied, will be capable of targeting the United States. Soon after, North Korea indeed conducted a series of missile launches.
Recently tested missiles are not capable of hitting the US, but they indicate serious and remarkably fast technological advancement - so remarkable that most foreign experts believe that Kim was not bluffing when he talked about North Korea's ability to develop ICBMs in the near future.
Shortly after these missile tests, in February, North Korean agents assassinated Kim Jong-nam, Kim Jong-un's elder brother, who lived in self-exile for nearly two decades.
He was ambushed and poisoned by the North Korean operatives in Kuala Lumpur airport. Kim Jong-nam never challenged Kim Jong-un openly, and always emphasised that he did not care about politics, but he was the only member of the Kim family who often talked to the foreign media, sometimes with remarkable frankness.
Kim Jong-nam's assassination coincided with yet another wave of purges inside North Korea, with another bunch of generals disappearing without any trace.
Chinese-style economic reforms
Meanwhile, inside North Korea, Kim Jong-un's administration continues to implement economic reforms, even though, unlike missile tests and overseas assassinations, these reforms seldom attract the attention of the world media.
In essence, these reforms are strikingly similar to what China did in the late 1970s. In North Korea, the Soviet-style command economy is gradually dismantled, while market economy and private entrepreneurship is increasingly accepted and encouraged.
For example, the state-run and state-owned farms have been largely disbanded in recent years, and family farms gradually became the country's major agricultural production units. The results were predictable: a significant increase in food production.
These events demonstrate the three major dimensions of Kim Jong-un's policy: he is strengthening his ability to deter a foreign attack, he is eliminating possible rivals in the country elite, and he is speeding up market-oriented - and rather successful - economic reforms.
These three policies serve one overriding goal: to keep Kim in power. The hereditary leader of North Korea wants to stay in power indefinitely, and thus he is trying to deal with the three major threats which he thinks might bring him and his regime down.
Three major threats to Kim's reign
The first of such threats is largely external. Kim is afraid of a US invasion and - given what happened in Iraq, a fellow member of the so-called "axis of evil", as well as in Libya - his fears are by no means paranoid.
He believes that the best way to counter a foreign threat is to have a full-scale nuclear force which would be capable of hitting the continental US.
He needs ICBMs, perhaps dozens of them, preferably on difficult-to-intercept mobile launchers, ready to be launched at short notice.
Such force, Kim and his people hope, will ensure that the US will not attack, and will not intervene in support of some internal revolution, should it erupt inside North Korea - like it happened in Libya.
If North Korean people learn how much their country is lagging behind its neighbours, they are likely to blame the Kim family, so Kim Jong-un understands that the only way to keep the population docile and obedient is to start economic growth, and the only way to do so is to introduce China-style reforms.
The second threat is internal. When Kim succeeded his father in December 2011, he was in his mid-20s and completely unknown.
He had good reasons to be afraid of the country's ageing generals and dignitaries who saw him as a political lightweight.
He could not rule out the possibility that the senior politicians, including some members of his own family, could switch their support to somebody else.
The North Korean leader also never forgot that his eldest brother was beyond his reach, living overseas, in Macao and Beijing, under Chinese protection.
Kim countered this threat with the purges and executions of all senior officials whose loyalty he does not fully trust - including his uncle and aunt who were initially appointed to act as advisers and quasi-regents.
Now that his spies have killed Kim Jong-nam, Kim Jong-un remains the only member of the Kim family with political clout. The assassination in Kuala Lumpur also undermined the Chinese ability to intervene in North Korean politics - and Kim Jong-un is deeply distrustful of China.
OPINION: Kim Jong-nam attack reveals true nature of North Korea
The third threat is also internal. North Korea is a very poor country: the per capita income gap between South and North Korea is the world's largest for two countries sharing a land border. It is estimated that South Korea's per capita income is at least 15 times bigger than the North's.
If North Korean people learn how much their country is lagging behind its neighbours, they are likely to blame the Kim family. Therefore, Kim Jong-un understands that the only way to keep the population docile and obedient is to start economic growth, and the only way to do so is to introduce China-style reforms.
All these policies are somewhat risky: the attempts to create a powerful deterrent might provoke a US military strike; excessive purges of the elite might - instead of terrifying them - bring about a conspiracy and a coup attempt; economic reforms might unleash social movements beyond the government's control.
However, given Kim's precarious situation, he has few alternatives to what he is doing now - and so far his policies have worked well.
Andrei Lankov is a professor of Korean Studies at Kookmin University in Seoul. He is the author of The Real North Korea: Life and Politics in the Failed Stalinist Utopia.
The views expressed in this article are the author's own and do not necessarily reflect Al Jazeera's editorial policy.